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
2 answers

How can using gettext help me here?

I am trying to set up a way to allow members to translate strings into other languages. You can see an example here: TRANSLATIONS TEST Someone recommended that I use php's native gettext() function for this, instead of what I am already using to…
SoLoGHoST
  • 2,673
  • 7
  • 30
  • 51
7
votes
1 answer

gettext not translating

I installed the php-gettext package, and phpinfo() shows that gettext is enabled. My app.po looks like: msgid "Welcome" msgstr "Willkommen auf meiner Homepage!" msgid "Hier you can find stuff about me." msgstr "Hier finden Sie Informationen uber…
MnomrAKostelAni
  • 458
  • 1
  • 4
  • 13
7
votes
1 answer

Localization of GUI built with Glade and Python (Gtk)

I have made an application using Glade and Python and I would like to make several localizations. I know how to localize strings that are in the Python code, I just encapsule all the strings that are supposed to be localized with _() and than…
Tomas Novotny
  • 7,547
  • 9
  • 26
  • 23
7
votes
4 answers

Django: How to force translation into a given language inside a template?

In a Django template, I need to transanlate some strings to a specific language (different from current one). I would need something like this: {% tans_to "de" "my string to translate" %} or {% blocktrans_to "de" %}my bloc to translate {%…
Pierre-Jean Coudert
  • 9,109
  • 10
  • 50
  • 59
7
votes
1 answer

How to convert po (gettext) to json?

I have installed po2json using npm install po2json I am getting below error: C:\windows\system32>po2json --errorlevel traceback fr.po fr.json processing 1 files... po2json: warning: Couldn't handle input file fr.po: Traceback (most recent…
rahulpatil
  • 71
  • 1
  • 3
7
votes
1 answer

PHP gettext: not all strings becomes translated

I have these two adjacent lines of code: : : And these translations in the .po file msgid "Product" // Translates msgstr "Produkt" msgid "Quantity" //…
O A Olsen
  • 96
  • 2
7
votes
2 answers

How to compile gettext translations in setup.py of a Django app

How can I make sure setup.py compiles projects PO files and include them whenever an sdist is created. This is a Django app and manual process to generate MO files is to run following command in the app's root directory: django-admin…
muhuk
  • 15,777
  • 9
  • 59
  • 98
7
votes
3 answers

PHP gettext function only returns original untranslated string

I'm trying to use gettext add localisation support to my website. I've followed various guides on how to setup gettext and have done the following: I've created the following files and directories in the root of my project dir: test.php locale/ …
Camsoft
  • 11,718
  • 19
  • 83
  • 120
7
votes
5 answers

Using gettext in bash

How to use gettext in bash script? I only found this page, but I don't understand it. Localization My script is written like this: #!/bin/bash . lang_file.sh echo $LANG_HELLO_WORLD And lang_file.sh look like that: #!/bin/bash …
lauriys
  • 4,652
  • 7
  • 32
  • 40
7
votes
2 answers

django: gettext and coercing to unicode

I have following code in my django application. class Status(object): def __init__(self, id, desc): self.id = id self.desc = desc def __unicode__(self): return self.desc STATUS = Status(0, _(u"Some text")) When I…
gruszczy
  • 40,948
  • 31
  • 128
  • 181
7
votes
1 answer

Extract untranslated strings from PO file

I would like to remove all translated strings from a PO file, or generate a PO file with only the untranslated strings. Is that possible?
Pere
  • 1,647
  • 3
  • 27
  • 52
7
votes
3 answers

How to make a header for gettext .po files?

I found most of the structure of .po files at the GNU Gettext manual. But the manual doesn't say anything about how to set a header. How do I make a header for gettext .po files? Thanks
Laus Brandt
7
votes
1 answer

What is bindtextdomain, textdomain in gettext?

I've been learning a bit of gettext but I can't grasp those two functions. I've been wondering if I could use multiple translations in a APP written in PHP. For an instance, I've 1) the system translation 2) extensions translations 3) theme…
allenskd
  • 1,795
  • 2
  • 21
  • 33
7
votes
3 answers

Gettext() with larger texts

I'm using gettext() to translate some of my texts in my website. Mostly these are short texts/buttons like "Back", "Name",... // I18N support information here $language = "en_US"; putenv("LANG=$language"); setlocale(LC_ALL, $language); // Set…
Nicolas.
  • 453
  • 1
  • 5
  • 27
7
votes
10 answers

EditText.getText().toString() sometimes returns ""

I get EditText's text and its length in onTextChanged() method of TextWatcher. It works fine when I type to add characters, but while removing characters from text getText() gives empty even if text is not empty. This occurs randomly and not…
Geek
  • 8,280
  • 17
  • 73
  • 137