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
34
votes
8 answers

Why do people use plain english as translation placeholders?

This may be a stupid question, but here goes. I've seen several projects using some translation library (e.g. gettext) working with plain english placeholders. So for example: _("Please enter your name"); instead of abstract placeholders (which has…
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
32
votes
3 answers

Is it possible to combine two .po translation files together?

We have two .po files, each from different branches of a piece of software. We need to combine these into a single .po file. There are duplicates between the two files, and the ideal handling would be for one file's strings to be favoured…
fooquency
  • 1,575
  • 3
  • 16
  • 29
31
votes
3 answers

Internationalisation Django (on OSX)

I'm trying to get gettext to work in Django on my OSX Leopard django_manage.py makemessages -l nl Importing Django settings module settings processing language nl Error: errors happened while running xgettext on __init__.py /bin/sh: xgettext:…
Cluesane
  • 311
  • 1
  • 3
  • 3
31
votes
8 answers

Translation in JavaScript like gettext in PHP?

I am using gettext in my PHP code, but I have a big problem. All my JavaScript files are not affected by the translation, can somebody tell me an easy way to get the translations in the chosen language into JavaScript as well.
ParisNakitaKejser
  • 12,112
  • 9
  • 46
  • 66
29
votes
3 answers

Symfony 'trans' domain inside Twig template

I'd like to do this: $this->get('translator')->trans('notice.unregistered', array(), 'index'); Inside Twig template, so I don't have to pass this as an argument. How?
Misiur
  • 5,019
  • 8
  • 38
  • 54
29
votes
6 answers

Django makemessages errors Unknown encoding "utf8"

I installed python separated from yum. Now, I need to recompile the language pack for the OSQA system, but get this message: Error: errors happened while running xgettext on __init__.py xgettext:…
digoferra
  • 1,001
  • 3
  • 17
  • 33
28
votes
10 answers

AppRegistryNotReady: The translation infrastructure cannot be initialized

When I try to access to my app, I'm getting the following error below: AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import…
Alexandre Tea
  • 313
  • 1
  • 3
  • 7
26
votes
3 answers

PHP translation frontend similar to Rosetta?

I'm currently migrating a web application from a database-based internationalization approach (each word having an entry in the translation table, and the actual translation) to one based on Zend_Translate and CSV files. I need to provide a end-user…
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
26
votes
1 answer

Gettext message catalogues from virtual dir within PYZ for GtkBuilder widgets

Is there an established approach to embed gettext locale/xy/LC_MESSAGES/* in a PYZ bundle? Specifically to have Gtks automatic widget translation pick them up from within the ZIP archive. For other embedded resources pkgutil.get_deta or…
mario
  • 144,265
  • 20
  • 237
  • 291
26
votes
9 answers

Django i18n: Common causes for translations not appearing

I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I…
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
25
votes
3 answers

Most efficient approach for multilingual PHP website

I am working on a large multilingual website and I am considering different approaches for making it multilingual. The possible alternatives I can think of are: The Gettext functions with generation of .po files One MySQL table with the…
alexteg
  • 2,830
  • 4
  • 24
  • 21
24
votes
6 answers

How to clear php's gettext cache without restart Apache nor change domain?

This is a little code snippet from php manual: putenv('LC_ALL=zh_CN'); setlocale(LC_ALL, 'zh_CN'); bindtextdomain('domain', './locale'); textdomain('domain'); echo gettext('Hello'); Which will output 你好 as defined in domain.mo file, but the…
xiaoyi
  • 6,641
  • 1
  • 34
  • 51
24
votes
3 answers

How to bind a text domain to a local folder for gettext under GTK3

With gettext you can either use the default system-wide locale directory, or specify one yourself using bindtextdomain. This is useful when running a program directly from source when the compiled .mo translation files are not available in the…
Emilien
  • 2,971
  • 2
  • 22
  • 32
23
votes
6 answers

Is there a Java library for parsing gettext PO files?

Does anyone know of a Java library that will let me parse .PO files? I simply want to create a Map of IDs and Values so I can load them into a database.
Mike Sickler
  • 33,662
  • 21
  • 64
  • 90
22
votes
3 answers

Parsing gettext `.po` files with python

I need to extract messages from .po files. Is there a Python module to do that? I wrote a parser, but it depends on platform (\r\n vs. \n). Is there a better way to do this?
alex
  • 521
  • 1
  • 5
  • 17