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

Using Babel: How to protect translator comments (and old translations) in GNU gettext PO files?

With the Python-based Babel gettext utilities, are there any techniques to preserve translator comments and old ("obsolete") translations (marked with #~) in .po files across updates from the .pot file? The first time an obsolete translation is in a…
Malcolm
  • 5,125
  • 10
  • 52
  • 75
10
votes
3 answers

Google translate service for GNU gettext PO files that supports ngettext style plurals

I'm looking for a front-end to google translate that supports translating GNU gettext PO files with NGETEXT style plurals, eg. msgid_plural, msgid[0] ... msgid[n]. I've found several free translation services for PO files [1], but none of these…
Malcolm
  • 5,125
  • 10
  • 52
  • 75
10
votes
4 answers

Django model translation : store translations in database or use gettext?

I'm in a Django website's I18N process. I've selected two potentially good django-apps : django-modeltranslation which modifies the db schema to store translations django-dbgettext which inspect db content to create .po files and uses gettext From…
10
votes
4 answers

Unable to append a translated string to himself with gettext

The following code is not working from django.utils.translation import gettext_lazy as _ stringtest=_("First string") stringtest= stringtest + _(" Second string") print stringtest I get the following exception: cannot concatenate 'str' and…
Erwan
  • 1,055
  • 1
  • 12
  • 26
10
votes
3 answers

Gettext not working through php-cli, but works in php-apache

The code i run looks as the following: ... $this->locale = da_DK; ... putenv("LC_ALL=".$this->locale); putenv('LANG='.$this->locale); $res = setlocale(LC_ALL, $this->locale); if($res != $this->locale){ throw new Exception("The language could…
CodeTower
  • 6,293
  • 5
  • 30
  • 54
10
votes
3 answers

Make translations in multiple languages

I have my php gettext default language in English let's say I would like in one of my controller, to translate some words in 2 other languages and put them all in an array. ideally I could do $word_sv = gettext($word, 'sv_SV'); $word_fi =…
user1125394
10
votes
1 answer

Translation of R script using gettext

Is it possible to use something like gettext to translate an R script. If so, how? If not, what other options I have?
evgeniuz
  • 2,599
  • 5
  • 30
  • 36
9
votes
1 answer

Python and gettext

I'm building a Python application that utilizes a bunch of translated strings. The directory structure housing said strings looks like this: /locales default.pot # reference English strings live here /es_ES /LC_MESSAGES …
brettkelly
  • 27,655
  • 8
  • 56
  • 72
9
votes
2 answers

WebDriver getText throws exceptions

Okay, I am completly clueless: I have table on the page where every rows has CSS ID incremented by one. And I am searching the Auction ID in such table and matching it with the Auction I entered through previous Selenium test. So my code goes like…
Pavel Janicek
  • 14,128
  • 14
  • 53
  • 77
9
votes
1 answer

gettext character encoding

I have the following gettext .po file, which has been translated from a .pot file. I am working on a Linux system (openSUSE if it matters), running gettext 0.17. # # , 2011 # transer , 2011 msgid…
CodeT
  • 91
  • 1
  • 3
9
votes
2 answers

How to get the text out of a scrolledtext widget?

I am new to the tkinter python module. I try to do a project. I learned something new about the menus and I'm trying to make a little UI project that allows the user to write something in a scrolled text widget and then save it (using the sys…
David
  • 624
  • 1
  • 6
  • 21
9
votes
1 answer

Angular 2 localization with Gettext ( .po files)

I have old legacy site translated of 4 different languages with Gettext and .po files. Now I am starting rebuilding of the site, and trying to use those files in new Angular2 site. Is there any way I could directly use .po files? I have tried…
Nutic
  • 1,407
  • 4
  • 16
  • 31
9
votes
2 answers

Can you "dumb down" ES6 template strings to normal strings?

I have to work around the limitation of gettext to recognise ES6 template strings, and I thought about getting the "non interpolated value" of the template strings as a compilation step, in order to have only "normal" strings in the code. Basically…
domokun
  • 3,013
  • 3
  • 29
  • 55
9
votes
1 answer

Chinese localization not worked with PHP gettext extension as it works with English

I'm already localized a website from Russian to English with PHP and gettext just with wrapping all strings into __($string) function. It works. Here's the gists: https://gist.github.com/Grawl/ba8f39b8398791c6a67e But it don't work with Chinese…
9
votes
2 answers

Internationalizing a Python 2.6 application via Babel

We're evaluating Babel 0.9.5 [1] under Windows for use with Python 2.6 and have the following questions that we we've been unable to answer through reading the documentation or googling. 1) I would like to use an _ like abbreviation for ungettext.…
Malcolm
  • 5,125
  • 10
  • 52
  • 75