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

Gettext support in OCaml

I'd like to get i18n working in my OCaml code (translating text messages into the user's preferred language). Most translatable strings are the first non-labelled argument to one of a small group of functions. e.g. Text output: print "Feed '%s':"…
Thomas Leonard
  • 7,068
  • 2
  • 36
  • 40
9
votes
5 answers

Selenium getText

I want to getText() using By.id or By.cssSelector. I managed to solve my problem by doing getAttribute("value"), but I don't understand why getText() doesn't work like I expect it, and I might need it so all help is appreciated. Here is the Java…
Lpgfmk
  • 391
  • 1
  • 4
  • 17
9
votes
4 answers

Pros and cons of using gettext instead of QObject.tr() for localization of PyQt4 application?

I have couple of application written in PyQt4 where I've used standard Python gettext library for internationalization and localization of GUI. It works good for me. But I've selected gettext just because I've already had knowledge and experience of…
bialix
  • 20,053
  • 8
  • 46
  • 63
9
votes
2 answers

Django JavaScript translation not working

I tried to follow the guide but it's not clear enough. I added this to my urls.py urlpatterns = patterns('', (r'^jsi18n/(?P\S+?)/$', 'django.views.i18n.javascript_catalog'), ) Generated the lang files using this…
Adam
  • 2,948
  • 10
  • 43
  • 74
9
votes
2 answers

gettext: extract dgettext() strings to domain.po files

I have program with multiple domains, some source files contain dgettext() calls with different text domains. How to extract gettext-strings to multiple .po files? For example, call dgettext('one', 'Hello') should go to one.po, and dgettext('two',…
Sergey Stolyarov
  • 2,587
  • 3
  • 27
  • 40
9
votes
2 answers

Combining keys and full text when working with gettext and .po files

I am looking at gettext and .po files for creating a multilingual application. My understanding is that in the .po file msgid is the source and msgstr is the translation. Accordingly I see 2 ways of defining msgid: Using full text (e.g. "My name is…
Max
  • 12,794
  • 30
  • 90
  • 142
9
votes
1 answer

Any way to alias a function name to '_'?

In Go, is there any circumstance where the gettext short-form of: _("String to be translated.") can be used? One of those times where I'm fairly certain the answer is 'no', but asking just in case I've overlooked something. I'm thinking the best…
Rich Churcher
  • 7,361
  • 3
  • 37
  • 60
9
votes
5 answers

pygettext.py and msgfmt.py on Mac OS X

I want to translate strings in my Python app on my Mac OS X 10.7. I can import the gettext module but i can't find the tools pygettext.py and msgfmt.py, which according to the Python docs should be somewhere in my Python installation. Is the…
verbit
  • 485
  • 8
  • 16
9
votes
3 answers

fputs( _("") ) what does the underscore stand for?

I finally got myself to look at some Linux code. I am looking right now at ls.c. At the function usage() at the bottom I found a lot of these statements: fputs (_("\ List information about the FILEs (the current directory by default).\n\ Sort…
user945967
8
votes
2 answers

How do I use multiple .mo files simultaneously for gettext translation?

In short, can I use in python many .mo files for the same language in the same time? In my python application, I need to use gettext for I18N. This app uses kind of a plug-in system. This means you can download a plug-in and put it in the…
jadkik94
  • 7,000
  • 2
  • 30
  • 39
8
votes
2 answers

PoEdit keywords - plurals

I incorporated a gettext-like localization system in my app, but my translation function looks like this: t($category, $string, [$plural_string, $number, $vprintf_arguments]) My PoEdit keywords: t:2 t:2,3 t:2 tells PoEdit to parse $string, and…
Alex
  • 66,732
  • 177
  • 439
  • 641
8
votes
2 answers

Can I automatically update msgids in gettext's .po files for trivial text changes?

With gettext, the original (usually English) text of messages serves as the message key ("msgid") for the translations. This means that every time the original text changes, the msgid must be updated in all the .po files. For real changes of the…
sleske
  • 81,358
  • 34
  • 189
  • 227
8
votes
2 answers

Installing gettext in windows :Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed

I followed the instructor of installing gettext on windows and when I type xgettext --version in my command prompt it says that it has installed. but when I want to run this command: python manage.py makemessages -l "fa" in my project it says Can't…
user6453511
8
votes
2 answers

Python: gettext doesn't load translations on Windows

This particular piece of code works very well on Linux, but not on Windows: locale.setlocale(locale.LC_ALL, '') gettext.bindtextdomain('exposong', LOCALE_PATH) gettext.textdomain('exposong') Code from here Even if i specify the locale in…
8
votes
1 answer

POEdit doesn't extract string in HTML tags

I'm having a problem with Laravel's blade templating syntax. When having something like: that string won't be founded by POEdit. But on same file if I had this: {{ __('My Tooltip')…
Miguel Oliveira
  • 421
  • 3
  • 7