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

Is there any git hook for pull?

I need to perform some actions (prepare gettext *.mo message files) on my project everytime I run git pull. Is there any suitable git hook, which I could use for this purpose please?
msgre
  • 2,253
  • 3
  • 14
  • 12
172
votes
4 answers

"gettext()" vs "gettext_lazy()" in Django

I have a question about using ugettext and gettext_lazy() for translations. I learned that in models I should use gettext_lazy(), while in views ugettext. But are there any other places, where I should use gettext_lazy() too? What about form…
Dzejkob
  • 2,302
  • 2
  • 15
  • 20
100
votes
11 answers

Compiler error - msgfmt command not found

I'm trying to update Git from my shared hosting. For that I'm following these steps: Download latest Git version Unpack and place it on the server Configure and create the Makefile -> ./configure --prefix=$HOME/dev/git/src --without-tcltk Build the…
John
  • 3,529
  • 14
  • 42
  • 48
63
votes
10 answers

django-admin.py makemessages not working

I am trying to translate a string. {% load i18n %} {% trans "Well, Hello there, how are you?" %} to... Hola amigo, ¿que tal? My settings.py file has this: LOCALE_PATHS = ( os.path.join(BASE_DIR, 'translations'), ) And I am getting…
broinjc
  • 2,619
  • 4
  • 28
  • 44
51
votes
8 answers

What good alternatives to Poedit are there?

I'm looking for a .po/.mo editor. I am using gettext for the translation files but don't really like Poedit. It has to run on Windows Vista and it would be even better if it was built into Visual Studio 2008 so I could develop and translate. I…
Thomaschaaf
  • 17,847
  • 32
  • 94
  • 128
49
votes
2 answers

How to use gettext with python >3.6 f-strings

Previously you would use gettext as following: _('Hey {},').format(username) but what about new Python's f-string? f'Hey {username}'
mdargacz
  • 1,267
  • 18
  • 32
49
votes
4 answers

Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. (Django 1.8 and OSX ElCapitan)

I'm trying to internationalize a Django app by following the wonderful Django documentation. The problem is when I try to run command to create language files: python manage.py makemessages -l fr It outputs an error : CommandError: Can't find…
Louis Barranqueiro
  • 10,058
  • 6
  • 42
  • 52
49
votes
11 answers

Gettext: Is it a good idea for the message ID to be the english text?

We're getting ready to translate our PHP website into various languages, and the gettext support in PHP looks like the way to go. All the tutorials I see recommend using the english text as the message ID, i.e. gettext("Hi there!") But is that…
Sean
  • 1,668
  • 1
  • 18
  • 28
41
votes
3 answers

complete example of gettext in php

i've been googling for the last hour or so trying to find a complete working example of gettext in php - all source files, po files, with proper paths, etc. Just a "hello world" with all the required files. I was wondering if anybody has such a…
Sherif Buzz
  • 1,218
  • 5
  • 21
  • 38
39
votes
6 answers

How do you handle translation of text with markup?

I'm developing multi-language support for our web app. We're using Django's helpers around the gettext library. Everything has been surprisingly easy, except for the question of how to handle sentences that include significant HTML markup. Here's a…
badr
39
votes
4 answers

Gettext .po files under version control

Currently using Gettext on a project and the .po files are nicely kept under version control. PO files of course contain translations, but in addition to that they also contain some metadata - information about the exact files and line numbers where…
Rene Saarsoo
  • 13,580
  • 8
  • 57
  • 85
36
votes
4 answers

How to convert gettext .mo file into .po file

Is there any way to convert a .mo file into a .po file source, when the .po file is no longer available? I need to edit the content of a .mo file but I don't have the .po file. Is it possible?
morteza
  • 361
  • 1
  • 3
  • 3
35
votes
4 answers

Alternatives to gettext?

Are there any general localization/translation alternatives to gettext? Open source or proprietary doesn't matter. When I say alternative to gettext, I mean a library for internationalization, with a localization backend of sorts. The reason I'm…
Tor Valamo
  • 33,261
  • 11
  • 73
  • 81
34
votes
3 answers

Django templates: Best practice for translating text block with HTML in it

In Django templates, how would I translate a block that contains HTML? For example: {% trans "Please" %} {% trans "log in" %} {% trans "in order to use MyApplicationName."…
AndiDog
  • 68,631
  • 21
  • 159
  • 205
1
2 3
99 100