Getting a localized string

I created localized fr_FR_Locale.mo files from fr_FR.po .

I used the sgettext, msginit and msgfmt command from the terminal.

I changed my local to French (fr_FR.utf8) .

But when I execute my code, I do not get what I expect. Here is my call:

setlocale(LC_ALL,"");
bindtextdomain("locale",LC_INTL);
bind_textdomain_codeset("locale", "UTF-8");
textdomain("locale");
printf(gettext("Hello world!"));   

Here the conclusion should be something not English , but I get the same English words .

+3
source share
2 answers

Please view the following message. It may come in handy for you.

End C ++ i18n gettext () "hello world" Example

0

, mo . , LC_INTL mo . , /usr/local/share/locale/fr/LC_MESSAGES/MyApp.mo, :

setlocale(LC_ALL,"");
bindtextdomain("MyApp","/usr/local/share/locale");
bind_textdomain_codeset("MyApp","UTF-8");
textdomain("MyApp");
0

Source: https://habr.com/ru/post/1782273/


All Articles