Questions tagged [gettext]

Gettext is an internationalization and localization (i18n) library which is commonly used for writing multilingual programs. Its most popular implementation is that of the GNU project.

Gettext is an internationalization and localization (i18n) library which is commonly used for writing multilingual programs. Its most popular implementation is that of the GNU project.

I18n with gettext works by marking up translatable strings in the source code, usually by wrapping them with a function call. The xgettext tool extracts these strings and creates a text file listing them. This file is called the template and its name usually ends in ".pot".

The msginit tool creates a new text file mapping the extracted strings to their translation in a given locale, having the ".po" extension. Finally the msgfmt tool creates an optimized representation of the translation mappings that is then used at runtime. For most programs this is a binary file ending in ".mo", but it is also possible to create other formats, for example a java ResourceBundle.

There are specialized editors for editing the ".mo" files, which can remember already translated strings and contain databases of repeatedly used words.

1756 questions
12
votes
3 answers

How does gettext handle dynamic content?

In php (or maybe gettext in general), what does gettext do when it sees a variable to dynamic content? I have 2 cases in mind. 1) Let's say I have poked John . Maybe in some language the order of the words is different. How…
Nathan H
  • 48,033
  • 60
  • 165
  • 247
12
votes
3 answers

PHP Gettext problems (like non-thread-safe?)

I want to start using gettext to handle my translations on web projects (PHP 5). Since it is a widely used standard with a good reputation it seems to be the best choice. However, I'm also hearing things about server incompatibly and it being…
Xeoncross
  • 55,620
  • 80
  • 262
  • 364
12
votes
4 answers

xgettext vs gettext

I have a few questions: I know what gettext is. I've read a few posts where they mentioned xgettext and was curious as to what is the difference between the two. How can I install xgettext on Windows? And finally, does anybody have a tutorial on…
Kentor
  • 657
  • 1
  • 10
  • 27
11
votes
2 answers

How can I check .mo file validity?

I'm using PHP to make .mo files out of the database and have run into a strange problem: some keys work, some don't. I think there is some kind of a problem with the generated files. How can I check, whether a .mo file is correct?
Fluffy
  • 27,504
  • 41
  • 151
  • 234
11
votes
7 answers

How to generate a new .pot template from a translated .po file

Having started off with an incomplete gettext .pot file, the resulting .po translations file now includes a large number of translation strings that were not originally in the .pot file. How can I backwards generate a .pot file for other languages…
richhallstoke
  • 1,519
  • 2
  • 16
  • 29
11
votes
3 answers

Switch gettext translated language with original language

I started my PHP application with all text in German, then used gettext to extract all strings and translate them to English. So, now I have a .po file with all msgids in German and msgstrs in English. I want to switch them, so that my source code…
Ruben
  • 3,452
  • 31
  • 47
11
votes
3 answers

CMake module for gettext support?

Is there a good, open-source, documented CMake module for gettext support? I mean: Extracting messages from sources Merging messages to existing translations Compilation of mo-files Installation of mo-files. Because plain macros that CMake…
Artyom
  • 31,019
  • 21
  • 127
  • 215
11
votes
5 answers

Using PHP Gettext Extension vs PHP Arrays in Multilingual Websites?

So far the only 2 good things that I've seen about using gettext instead of arrays is that I don't have to create the "greeting" "sub-array" (or whatever its called). And I don't have to create a folder for the "default language". Are there other…
alexchenco
  • 53,565
  • 76
  • 241
  • 413
11
votes
1 answer

How to create .po files using xgettext on Windows?

I'm following this tutorial about building a multilingual web sites using PHP gettext http://onlamp.com/pub/a/php/2002/06/13/php.html I understand the tutorial until this part: After you have the directories all prepared, it's time to create the …
alexchenco
  • 53,565
  • 76
  • 241
  • 413
11
votes
5 answers

Recursive xgettext?

How can I compile a .po file using xgettext with PHP files with a single command recursively? My PHP files exist in a hierarchy, and the straight xgettext command doesn't seem to dig down recursively.
neezer
  • 19,720
  • 33
  • 121
  • 220
11
votes
4 answers

gettext, how to handle homonyms?

Using gettext Single value echo gettext( "Hello, world!\n" ); Plurals printf(ngettext("%d comment", "%d comments", $n), $n); English homonym? echo gettext("Letter");// as in mail, for Russian outputs "письмо" echo gettext("Letter");// as in…
Timo Huovinen
  • 53,325
  • 33
  • 152
  • 143
11
votes
6 answers

PHP gettext on Windows

There are some tutorials out there for gettext (with Poedit)... unfortunately, it's mostly for a UNIX environment. And even more unfortunate is that I am running my WAMP server on Windows XP (but I am developing for a UNIX environment) and none of…
axsuul
  • 7,370
  • 9
  • 54
  • 71
11
votes
2 answers

How to convert GNU Gettext .po files to Qt's .ts files?

Is there a tool to convert the translations in GNU Gettext .po format into Qt's native .ts format?
v_2e
  • 2,603
  • 2
  • 22
  • 29
10
votes
3 answers

Merge 2 GetText files

I have two medium-sized web applications that I'm merging into one. They are both localized with GetText and have large amout of common strings, so merging them manually would be extremely annoying. What is the fastest way to merge the two PO files?
Matěj Zábský
  • 16,909
  • 15
  • 69
  • 114
10
votes
3 answers

Why doesn't gettext have a db storage option?

I'm doing some i18n on a web-based app using Django, which uses gettext as its i18n foundation. It seems like an obvious idea that translations should be stored in the database, and not difficult to do, but po files on the filesystem are still…
JivanAmara
  • 1,065
  • 2
  • 10
  • 20