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
7
votes
1 answer

Xml getText return null - Android

i'm using XmlPullParser on Android but get getText return null. Why is this happening? The code, the commented line gives the null ArrayList titleList = new ArrayList(); try { XmlPullParserFactory factory =…
Clepto
  • 685
  • 1
  • 6
  • 7
7
votes
1 answer

gettext for HTML or LaTeX?

Is there something like gettext for HTML or LaTeX? It would be great for generating simple bilingual webpages or LaTeX documents that should be kept in sync. Is there something like that already? I guess there must be some Perl script for that, but…
Jay
  • 9,585
  • 6
  • 49
  • 72
7
votes
4 answers

how to generate po file from js file using poedit

i am using Gettext.js library to localize my contents generated from a JS file. Now the situation is, i have to create and write each and every po files manually. I know we can scan php files for gettext strings using PoEdit. So, is it possible to…
Prasanth K C
  • 7,073
  • 5
  • 39
  • 62
7
votes
2 answers

i18n with gettext but without the locale hassle?

I am looking for a standards-compliant way to store multi-language content for a Web Application. Until now, I have employed my own "translate()" functions that read data from a file or a dictionary table in a database. However, keeping the…
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
7
votes
3 answers

Is it possible to generate a single .pot file from Sphinx documentation?

I'm undergoing the task of i18n / l10n the documentation of a largish project. The documentation is done with Sphinx, that has off-the shelf basic support for i18n. My problem is similar to that of this other question: namely the fact a large chunk…
mac
  • 42,153
  • 26
  • 121
  • 131
7
votes
2 answers

Benefits of keeping gettext's .mo files in repo

For example, why authors of "django-cms" keep gettext's mo files in repo (and this is not just inattention, see this commit), if users always can run manage.py compilemessages? Only to save users from this step and make installation process a little…
neoascetic
  • 2,476
  • 25
  • 34
7
votes
6 answers

PHP Gettext - No translation

I am trying to use the PHP gettext extension in order to translate some strings. All functions appear to return the correct values but calling gettext()/_() returns the original string only. The PO/MO files seem correct and I believe I have set…
pb149
  • 2,298
  • 1
  • 22
  • 30
7
votes
4 answers

Extracting Javascript gettext messages using Babel CLI extractor

It is stated here that Babel can extract gettext messages for Python and Javascript files. Babel comes with a few builtin extractors: python (which extracts messages from Python source files), javascript, and ignore (which extracts…
Basel Shishani
  • 7,735
  • 6
  • 50
  • 67
6
votes
1 answer

Django: keep lazy translation when composing translated strings

In Django, I'm happily using ugettext_lazy to pospone the translation of a string only when its representation is needed. The problem is that when I concatenate a lazy string to a normal string or when I use its methods (e.g. capitalize() ), the…
Don
  • 16,928
  • 12
  • 63
  • 101
6
votes
1 answer

i18n with jinja2 + GAE

I googled for a GAE + jinja i18n example but could not find it. Can anyone provide a link or working example? My effort uses the django translations and I don't know if this is the recommend way of doing it. import jinja2 from django.utils import…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
6
votes
2 answers

Why does gettext translate an empty string to the .po header text?

I've got gettext setup within PHP5. After some struggling with the charactersets and the like, I've managed to translate some basic strings. Now I've ran into a problem. When translating an empty string I expect to get the untranslated (empty)…
Timo
  • 2,212
  • 2
  • 25
  • 46
6
votes
4 answers

override gettext .mo files

For translations in our application, we're using Zend Translate with the gettext adapter. In each module is a folder translations, containing .mo files for all the languages; da.mo nl.mo en.mo Which are scanned and added through the…
Rijk
  • 11,032
  • 3
  • 30
  • 45
6
votes
2 answers

How to exclude DBGrid.Column.FieldName in .pot file

I made an application with Delphi 6. After that I extracted a .pot file with all the strings to translate. The problem is that there are strings that don't have to be tranlated, and if translated will generate problems. Une of this is…
6
votes
4 answers

What should I know to make my I18N application work in Japanese?

I'm working on a I18N application which will be located in Japanese, I don't know any word in Japanese, and I'm first wondering if utf8 is enough for that language. Usually, for European language, utf8 is enough, and I've to set up my database…
Boris Guéry
  • 47,316
  • 8
  • 52
  • 87
6
votes
1 answer

What is the best way to localize Markdown files in Weblate?

So I have been trialling Weblate using Docker, and pointing it at a Git repo with some .md files I want to localize. I believe a good way of doing this is to use po4a to first convert the .md (basically text) files to a Gettext .pot file then import…
Dominic Porter
  • 103
  • 1
  • 8