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

How can I escape '%' character in a gettext string?

I use gettext to translate my user interface. I'd like to write symbol % as part of a UI caption in a string, but since it has a special meaning, does not works as expected. How can I escape percent symbols?
viam0Zah
  • 25,949
  • 8
  • 77
  • 100
14
votes
3 answers

What does '_' do in Django code?

Why does this Django code use _ in front of 'has favicon' has_favicon = models.BooleanField(_('has favicon'))
zjm1126
  • 63,397
  • 81
  • 173
  • 221
13
votes
1 answer

What are the different gettext file formats used for?

I started trying to translate a few of the most used text entries in a C program using gettext, but when digging into this I got a little bit confused about all the different file formats since there seems to be some overlap in functionality? I…
hlovdal
  • 26,565
  • 10
  • 94
  • 165
13
votes
1 answer

Python : No translation file found for domain using custom locale folder

I have the following structure : / |- main.py |- brainz | |- __init__.py | |- Brainz.py |- datas |- locale |- en_US |- LC_MESSAGES |- brainz.mo |- brainz.po In my…
MARTIN Damien
  • 996
  • 2
  • 15
  • 36
13
votes
3 answers

How to I mark an empty translation (msgstr) as translated in po gettext files?

I found that is the translation for a string (msgid) is empty all gettext tools will consider the string as untranslated. Is there a workaround for this? I do want to have an empty string as the translation for this item.
sorin
  • 161,544
  • 178
  • 535
  • 806
13
votes
1 answer

Extracting gettext strings from Javascript and HTML files (templates)

I know that there are at least two ways to extract gettext strings from .js files - using the gettext parser in python mode (which I've heard has some shortcomings) and Babel, which is written in python. Is there way to extract gettext strings from…
ragulka
  • 4,312
  • 7
  • 48
  • 73
13
votes
1 answer

msgfmt "invalid multibyte sequence" error on a Polish text

Using Complete C++ i18n gettext() “hello world” example I changed the locale from "es_MX" to "pl_PL" and the text from "hello, world!" to "Invalid input. Enter a string at least 20 characters long.". The Polish translation contains several…
CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
12
votes
3 answers

Detecting Errors in .po files

I'm using a set of .po files generated by the company translation system (with Pootle, if that's relevant). I'm having trouble converting these files to .mo (the binary counterpart to .po files) using the msgfmt utility (with the -C operator, which…
brettkelly
  • 27,655
  • 8
  • 56
  • 72
12
votes
1 answer

Gettext automatic comments generation

I'm doing i18n for a php project using gettext. I'd like to use the automatic comment feature to give hints to translators when translating long phrases replaced by id. What I want to obtain is the following po file #:…
Fabio
  • 18,856
  • 9
  • 82
  • 114
12
votes
3 answers

Localization of ASP.NET MVC websites with GNU Gettext?

This might be an unusual question, but is there any framework or at least some helper classes that would help me use GNU Gettext for localizing a C# ASP.NET MVC website? I've been using Gettext in a previous (managed code) project and really…
Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210
12
votes
1 answer

How can I debug php gettext?

Some gettext keys aren't working for me - they show the key instead of the translation, though there is one. I'm making .mo file with PHP File_Gettext Pear library, and it seems to be working ok, so I've made the following script to try out, which…
Fluffy
  • 27,504
  • 41
  • 151
  • 234
12
votes
2 answers

Java and GNU gettext for internationalization

Has anyone had any experiences developing large Java applications using GNU gettext for internationalization? I find that I really like having the English text in my source code, but I want to make sure that what I'm doing is practical for the…
dcstraw
  • 3,243
  • 3
  • 29
  • 38
12
votes
3 answers

gettext() equivalent in Intl library?

I'm looking for a way to to do i18n and l10n. I've used gettext before and it was good: I would simply create .mo files in different languages and everything that needed to be translated would be in this notation: echo __('string to be…
Stann
  • 13,518
  • 19
  • 65
  • 73
12
votes
7 answers

Gettext will always use system default locale

I need to localise a Windows-only PHP web application and I'm evaluating the gettext extension but I'm having the hardest time trying to make it work in my Windows 7 development box. I've used trial and error together with Process Monitor to…
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
12
votes
2 answers

How to create an internationalized Google App Engine application

I would like to provide my Python GAE website in the user's own language, using only the tools available directly in App Engine. For that, I would like to use GNU gettext files (.po and .mo files). Has someone successfully combined Python Google…
Emilien
  • 2,971
  • 2
  • 22
  • 32