How to add multilanguage support to a Yocto build?
The locales were not generated because the IMAGE_LINGUAS variable was overwritten into another place (my fault).
The locales generated with IMAGE_LINGUAS, e.g. "en_GB" or "en_US", does not have the ".UTF-8" suffix in their name but they use the UTF-8 encoding. To check if a locale is UTF-8 refer to: https://stackoverflow.com/a/42797421/5321161
How to check if a locale is UTF-8?
LC_IDENTIFICATION
doesn't tell you much:
LC_IDENTIFICATION - this is not a user-visible category, it contains information about the locale itself and is rarely useful for users or developers (but is listed here for completeness sake).
You'd have to look at the complete set of files.
There appears to be no standard command-line utility for doing this, but there is a runtime call (added a little later than the original locale functions). Here is a sample program which illustrates the function nl_langinfo
:
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>
int
main(int argc, char **argv)
{
int n;
for (n = 1; n < argc; ++n) {
if (setlocale(LC_ALL, argv[n]) != 0) {
char *code = nl_langinfo(CODESET);
if (code != 0)
printf("%s ->%s\n", argv[n], code);
else
printf("?%s (nl_langinfo)\n", argv[n]);
} else {
printf("? %s (setlocale)\n", argv[n]);
}
}
return 0;
}
and some output, e.g., by foo $(locale -a)
:
aa_DJ ->ISO-8859-1
aa_DJ.iso88591 ->ISO-8859-1
aa_DJ.utf8 ->UTF-8
aa_ER ->UTF-8
aa_ER@saaho ->UTF-8
aa_ER.utf8 ->UTF-8
aa_ER.utf8@saaho ->UTF-8
aa_ET ->UTF-8
aa_ET.utf8 ->UTF-8
af_ZA ->ISO-8859-1
af_ZA.iso88591 ->ISO-8859-1
af_ZA.utf8 ->UTF-8
am_ET ->UTF-8
am_ET.utf8 ->UTF-8
an_ES ->ISO-8859-15
an_ES.iso885915 ->ISO-8859-15
an_ES.utf8 ->UTF-8
ar_AE ->ISO-8859-6
ar_AE.iso88596 ->ISO-8859-6
ar_AE.utf8 ->UTF-8
ar_BH ->ISO-8859-6
ar_BH.iso88596 ->ISO-8859-6
The directory names you're referring to are often (but not required) to be the same as encoding names. That is the assumption made in the example program. There was a related question in How to get terminal's Character Encoding, but it has no useful answers. One is interesting though, since it asserts that
locale charmap
will give the locale encoding. According to the standard, that's not necessarily so:
The command
locale charmap
gives the name used inlocaledef -f
However,
localedef
attaches no special meaning to the name given in the-f
option.localedef
has a different option-u
which identifies the codeset, butlocale
(in the standard) mentions no method for displaying this information.
As usual, implementations may (or may not) treat unspecified features in different ways. The GNU C library's documentation differs in some respects from the standard (see locale
and localedef
), but offers no explicit options for showing the codeset name.
Related Topics
Pipe Tar Extract into Tar Create
Using for Loop to Move Files from Subdirectories to Parent Directories
How to Setup Virtualhosts to Point Two Ports on Same Ip to Different Servernames
Kernel Oops Page Fault Error Codes for Arm
Is There Any General Interfaces on Linux to Simulate Mouse Movements and Click
Accept Multiple Lines of Input in a Bash Script
Running Linux Container on Docker Windows
.Dat Attachment Instead of Text Using Mailx in Redhat Linux
Installing a Fully Functional Postgis 2.0 on Ubuntu Linux Geos/Gdal Issues
Changing /Proc/Sys/Kernel/Core_Pattern File Inside Docker Container
When Compiling Programs to Run Inside a Vm, What Should March and Mtune Be Set To
Kaggle API Issue "Could Not Find Kaggle.JSON. Make Sure It's Located In......"
Oracle Query - Ora-01652: Unable to Extend Temp Segment But Only in Some Versions of Sql*Plus
Gnome-Terminal New Tab with Alias as Command to Execute