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
6
votes
3 answers

UTF-8 error with Python and gettext

I use UTF-8 in my editor, so all strings displayed here are UTF-8 in file. I have a python script like this: # -*- coding: utf-8 -*- ... parser = optparse.OptionParser( description=_('automates the dice rolling in the classic game "risk"'), …
Martin Ueding
  • 8,245
  • 6
  • 46
  • 92
6
votes
1 answer

Gettext placeholders

I am building a multilingual application in PHP + CodeIgniter. I have settled upon using gettext for UI text translation, and so far it has proven efficient and easy to work with. But now I am facing something really annoying: the gettext() function…
mingos
  • 23,778
  • 12
  • 70
  • 107
6
votes
2 answers

What are the reasons to use or to not use PHP's native gettext versus a self-build?

To make my application multilingual I'm wondering if there are big advantages to GNU's gettext or if there are big disadvantages of building your own 'library'. Also if 'build your own' is more advised, what are the best practices? Obviously they…
Gerben Jacobs
  • 4,515
  • 3
  • 34
  • 56
6
votes
1 answer

Python gettext - not translating

Sample python program: [CGI script, so it needs to select its own language rather than using whatever the host OS is set to] import gettext gettext.install('test', "./locale") _ = gettext.gettext t = gettext.translation('test', "./locale",…
OJW
  • 4,514
  • 6
  • 40
  • 48
6
votes
4 answers

Compile Git without gettext

I'm trying to compile a static Git 2.17.1 on Debian (Windows Subsystem for Linux): $ mkdir _git $ make configure $ ./configure --prefix=$PWD/_git NO_TCLTK=true NO_GETTEXT=true CFLAGS="${CFLAGS} -static" $ make all but I'm getting the error ... …
Thomas S.
  • 5,804
  • 5
  • 37
  • 72
6
votes
3 answers

How to use po/pot files with php?

I have a .po and a .mo file in a folder whose address is /locale/nld_nld/LC_MESSAGES/. Both the files' names are messages. I've been trying to use the following code: try.php: the…
Rajat Sharma
  • 61
  • 1
  • 2
6
votes
3 answers

Django i18n: is there a gettext alternative?

I'm looking for a way to translate my Django project. Built in mechanism provided with Django is great, but has several weak points which made me go looking for an alternative. Project owner must be able to edit every translation including English…
Silver Light
  • 44,202
  • 36
  • 123
  • 164
6
votes
2 answers

How to add directories to the Library search paths for autoconf

I'm just getting started with autotools, and have followed A. Duret-Lutz's tutorial closely to get a working C hello world that uses GNU gettext. The AM_CFLAGS and AM_LDFLAGS are set appropriately in the Makefile.am, and the code compiles and runs…
klmanion
  • 63
  • 1
  • 5
6
votes
1 answer

Django Makemessages CommandError ASCII Encoding

the locale/django.po file has 7868 lines. Sometimes the makemessages command works and sometimes it throws this error: Its strange because in the error is always a different line of django.pot mentioned. And don't forget that it sometimes works with…
ChrisRob
  • 1,515
  • 2
  • 18
  • 30
6
votes
1 answer

how to translate using gettext on xampp server on OS X El Capitan version 10.11.6

I am working on a website that is using gettext for translation. The website is translating properly on servers of other machines but not on mine (OS X El Capitan version 10.11.6). I have follow the following tutorial to install gettext on mac: link…
Kamga Simo Junior
  • 1,679
  • 2
  • 16
  • 30
6
votes
0 answers

Translating %% with gettext and jinja2 and pyramid

Doing i18n work with Python using Jinja2 and Pyramid. Seems to have a problem knowing how it should translate %%. I'm beginning to suspect the bug is in Jinja2. So I've done some more investigation and it appears the problem is more with gettext…
boatcoder
  • 17,525
  • 18
  • 114
  • 178
6
votes
3 answers

gettext translation not working on production system

I've encountered a strange problem when translating strings (in the admin) using django's gettext: Locally running the dev server all translations are displayed correctly in the admin, but when the project is deployed on the production server some…
Bernhard Vallant
  • 49,468
  • 20
  • 120
  • 148
6
votes
3 answers

Django makemessages for apps in site-packages

How can I collect translation strings outside of my project folder using Django's built-in makemessages facility? The management command makemessages is very convenient and I'd like to use it for applications located in site-packages.
viam0Zah
  • 25,949
  • 8
  • 77
  • 100
6
votes
3 answers

dxgettext and Windows 10

Has anyone got dxgettext running under Windows 10? I installed dxgettext from the offical homepage under Windows 10, which worked fine. But whenever I try to run some of the installed tools (e.g. msgfmt.exe), they don't really run, but call…
Alois Heimer
  • 1,772
  • 1
  • 18
  • 40
6
votes
5 answers

python gettext: specify locale in _()

I am looking fo a way to set the language on the fly when requesting a translation for a string in gettext. I'll explain why : I have a multithreaded bot that respond to users by text on multiple servers, thus needing to reply in different…