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
18
votes
4 answers

How can I merge 2 .POT files (translation files)

I have the following situation: One product which I want to translate, that has two separate websites, one for admins, one for customers. The codebase is CakePHP. Both sites are completely separate from each other, they are complete CakePHP…
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
18
votes
2 answers

PHP/Gettext Problems

I remember running some tests a some months ago with gettext and the following code worked perfectly: putenv('LANG=l33t'); putenv('LANGUAGE=l33t'); putenv('LC_MESSAGES=l33t'); if (defined('LC_MESSAGES')) // available if PHP was compiled with…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
18
votes
3 answers

Complete C++ i18n gettext() "hello world" example

I am looking for a complete i18n gettext() hello world example. I have started a script based upon A tutorial on Native Language Support using GNU gettext by G. Mohanty. I am using Linux and G++. Code: cat >hellogt.cxx <
CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
17
votes
2 answers

python gettext error: Can't convert '__proxy__' object to str implicitly

I'm suddenly getting a weird error in code that was previously working. I recently upgraded to Django 1.9.6 from 1.9.4. In one of my views, I have: from django.contrib import messages from django.utils.translation import ugettext_lazy as…
Escher
  • 5,418
  • 12
  • 54
  • 101
17
votes
2 answers

Multiple plural forms in gettext()

See this example of _n(); function (http://codex.wordpress.org/Function_Reference/_n): sprintf( _n('%d comment.', '%d comments.', $number, 'text-domain'), $number ); in English: 1 Comment 2 Comments in languages such as Polish there is a different…
Atadj
  • 7,050
  • 19
  • 69
  • 94
16
votes
3 answers

Gettext : How to update po and pot files after the source is modified

I've got a python project with internationalized strings. I've modified the source codes and the lines of the strings are changed, i.e. in pot and po files lines of he strings are not pointing to correct lines. So how to update the po and pot files…
deimus
  • 9,565
  • 12
  • 63
  • 107
16
votes
3 answers

Handling grammatical gender with Gettext

I'm looking for a simple-proper-elegant way to handle grammatical gender with Gettext in a Rails application, the same way plurals are handled with n_() method. This has no interest in english, since words don't vary with gender, but it does when…
dgilperez
  • 10,716
  • 8
  • 68
  • 96
16
votes
10 answers

Android: Check if EditText is Empty when inputType is set on Number/Phone

I have an EditText in android for users to input their AGE. It is set an inputType=phone. I would like to know if there is a way to check if this EditText is null. I've already looked at this question: Check if EditText is empty. but it does not…
yesButNotReally
  • 162
  • 1
  • 1
  • 7
16
votes
3 answers

What does #, fuzzy mean at the top of a xgettext-generated .pot file?

When using xgettext to generate a .pot file, at the top of the generated file I get this: # SOME DESCRIPTIVE TITLE. ... #, fuzzy ... What does the #, fuzzy mean? I know what it means if a translation is fuzzy (it is poor quality), but what does it…
user1318194
16
votes
1 answer

Variables in PHP gettext

Possible Duplicate: How does gettext handle dynamic content? I'm using PHP's gettext. I want to translate a sentence which has a variable in it. Is this possible? For example, in English: Are you sure you want to block Alice? (Where "Alice" is…
Terence Eden
  • 14,034
  • 3
  • 48
  • 89
15
votes
3 answers

Use PHP Gettext without having to install locales

I've been looking at options for internationalizing an open source project: Gettext, which everyone seems to recommend, apparently needs locales to be "installed on your system" to be used. See this note on the PHP manual, which reflects exactly my…
user1318194
14
votes
1 answer

Flask-Babel how to use translation in Jinja template file

In my Flask application, in main.py file, I defined: from flaskext.babel import gettext .... def somefun(): return render_template('some.html', messages=messages) in template file some.html, I used: python
Brent Jiang
  • 377
  • 1
  • 2
  • 11
14
votes
3 answers

Translating longer texts (view and email templates) with gettext

I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I need to translate with gettext. These are email templates (usually short, but still several lines) and parts of view templates (longer descriptive blocks of…
lanzz
  • 42,060
  • 10
  • 89
  • 98
14
votes
3 answers

Removing all fuzzy entries of a PO file

Does anyone know a method to mass delete all fuzzy translations from a PO file. Something like: if #, fuzzy == TRUE Then SET msgstr="" AND REMOVE #, fuzzy
Martijn Burger
  • 7,315
  • 8
  • 54
  • 94
14
votes
6 answers

How to install gnu gettext (>0.15) on windows? So I can produce .po/.mo files in Django

When runing django make messages: ./manage.py makemessages -l pt I get: CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. I tried to install but the last version I find with an Instalation Setup is…
NBajanca
  • 3,544
  • 3
  • 26
  • 53