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

How do you use gettext when you have link into the translated text?

I use gettext to translate my web site. It would be nice to have link in text translated but I don't want to write html tags in gettext files because these translations may be used elsewhere. I could create text for web site only (with links) and…
Luc M
  • 16,630
  • 26
  • 74
  • 89
8
votes
3 answers

Django makemessages javascript (xgettext)

I want to use django i18n support to translate my javascript files. I have the following javascript file: var test_text = gettext('example'); @withStyles(styles) export default class HomePage { static contextTypes = { i18n: PropTypes.object …
ilse2005
  • 11,189
  • 5
  • 51
  • 75
8
votes
2 answers

How to efficiently work with gettext PO files when making small edits to large text values

Looking for tips and/or tools on how to efficiently work with gettext PO files when making small edits to large msgid values. Example: We have lots of multi-sentence/multi-paragraph messages that are stored in our PO message catalog files. If we…
Malcolm
  • 5,125
  • 10
  • 52
  • 75
8
votes
4 answers

Localization in Perl using gettext and Locale::TextDomain, with fallback if Locale::TextDomain is not available

The "On the state of i18n in Perl" blog post from 26 April 2009 recommends using Locale::TextDomain module from libintl-perl distribution for l10n / i18n in Perl. Besides I have to use gettext anyway, and gettext support in Locale::Messages /…
Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
8
votes
1 answer

Internationalising sentences with two plural words

Using gettext how should a sentence with multiple numeric variables be made translatable? ngettext only takes one number as the plural parameter. The permutations that should be allowed in the below sentence are "adult and child", "adults and…
dsas
  • 1,650
  • 18
  • 30
8
votes
2 answers

performance overhead of the gettext internationalization system in C/C++

I just worked through the documentation of http://www.gnu.org/software/gettext/manual/gettext.html and there is no discussion at all about the performance overhead. On the internet, I found only performance discussions for other languages (PHP and…
Robby75
  • 3,285
  • 6
  • 33
  • 52
8
votes
4 answers

What is so good about gettext for language files?

Everywhere on SO when it comes to making a multi language app in PHP everyone say that gettext is the best way to do it. I am just wanting to know why? Like what makes this method below, less efficient then using gettext?
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
8
votes
4 answers

Is gettext the best way to localise a website in php? (only mild localisation needed)

Is gettext the best way to localise a website in php? I'm not using any frameworks, and there are not many words to translate, just two mildly different versions in English.
Ric
  • 3,195
  • 1
  • 33
  • 51
8
votes
2 answers

Command or option for the xgettext, msginit, msgfmt sequence for setting the MIME type?

msgfmt “invalid multibyte sequence” error on a Polish text is corrected by manually editing the MIME Content-Type charset in the template file. Is there some command or option for the xgettext, msginit, msgfmt sequence for setting the MIME type? cat…
CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
8
votes
2 answers

How to automatically remove unused gettext strings?

I have a web application where I have several translations using gettext. But now I have done a major rewrite of the application and while most of the strings are the same, there are also quite a few that were changed significantly or removed. I…
getSurreal
  • 347
  • 5
  • 10
7
votes
4 answers

poedit workaround for dynamic gettext

I have started using gettext for translating text and messages i send to user. I am using poedit as an editor, but i am struggling with dynamic messages. For example i have things like the login where i have a variable that tells the type of…
Gabriel Solomon
  • 29,065
  • 15
  • 57
  • 79
7
votes
2 answers

Is there a PHP library for parsing gettext PO POT files?

if is not in PHP, is possible use some command line tools which convert PO file into some structured format e.g. XML or some other which I can simple process in PHP?
MarekLi
  • 941
  • 1
  • 12
  • 18
7
votes
2 answers

Django makemessages "struct.error: unpack requires a buffer of 4 bytes"

I have a django instance packed in Docker container in docker-compose. I'm trying to generate makemessages files for project, but when I try to run makemessages, that's what I receieve in response root@6fc510c9c5d1:/code# python manage.py…
AndreyPanferov
  • 103
  • 1
  • 9
7
votes
4 answers

Testing django internationalization - Mocking gettext

I'm internationalizing/i18n-ing a django project. We have one part that runs independently and performs background tasks. It's called by rabbitmq. I want to test that the i18n/l10n works for that part. However our app isn't translated yet, and won't…
Amandasaurus
  • 58,203
  • 71
  • 188
  • 248
7
votes
3 answers

Rename Related Products title in Woocommerce 3

I used to have the following function working to change to Related Products text in Woocommerce. function my_text_strings( $translated_text, $text, $domain ) { switch ( $translated_text ) { case 'Related Products' : …
Joe Bloggs
  • 1,410
  • 2
  • 24
  • 53