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

How to make PoEdit correctly parse custom "ngettext" implementation?

I've coded a gettext wrapper that makes the whole process of l10n a little bit simpler but somehow I can't get PoEdit to correctly identify and parse plural version calls to the function. This is what I originally had: _e(array('%d house', '%d…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
6
votes
2 answers

Can't find msguniq. Django 1.8, Windows 7 64 bit

I've successfully installed msguniq (can check its version), I've tried to change compatibility to windows xp and run it as administator, but still I'm getting this error: CommandError: Can't find msguniq. Make sure you have GNU gettext tools …
stott3r
  • 63
  • 1
  • 7
6
votes
1 answer

undefined reference to `libintl_gettext' with MinGW/MSYS and CMake

I am trying to add gettext to a C++ project. It compiles and runs fine under Linux, but I get a linker error with MinGW32 in Windows 7 64 bit. I am compiling with cmake -G "MSYS Makefiles" .., because MinGW doesn't work for soe nebulous reason. I…
GunChleoc
  • 107
  • 1
  • 7
6
votes
3 answers

Finding missing translations in django `.po` files

Working with Django, you can use django.utils.translation.ugettext and ....ugettext_lazy (as well as some template tags) to handle translation of localized messages. Later, with command: django-admin.py makemessages -l you can generate…
FSp
  • 1,545
  • 17
  • 37
6
votes
2 answers

PHP and Gettext don't work on my server

I have a website. I'm trying to get gettext to work so that my English, Sweden and Norway sites can come up. I can't get it to work. What have I done wrong? This is my config code: // define constants ( defualt - danish ) $lang =…
ParisNakitaKejser
  • 12,112
  • 9
  • 46
  • 66
6
votes
7 answers

Change or translate specific texts in Woocommerce

I found a solution online for this but it does not seem to work. It says to edit the below file which I did a few days ago but somehow it is not working still. /wp-content/plugins/woocommerce/templates/single-product/related.php Which if I FTP to…
Mike Young
  • 321
  • 2
  • 4
  • 15
6
votes
1 answer

localize ordinal numbers

for ($rank=0; $rank<100; $rank++) { printf("Your rank: %d%s", $rank, $suffix); } Does there exist a gettext function to localize $suffix to the current language and return, for example: Your rank: 0th Your rank: 1st Your rank:…
abernier
  • 27,030
  • 20
  • 83
  • 114
6
votes
2 answers

Python gettext UnicodeDecodeError

I use python gettext module. It is fine when I use language=en_US, but it raises an error when I use another language (e.g:vi_VN). Have I done something wrong? trans = gettext.translation(domain, os.path.join(os.getcwd(), 'locales'),…
hungneox
  • 9,333
  • 12
  • 49
  • 66
6
votes
1 answer

angularjs/gettext: how to translate text in attributes

I have a piece of html like this Now, when I want to translate it, it looks like this The reason why I dont have {{ and }} is because the 'bar' directive binds the title to…
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
6
votes
2 answers

How to use GNU gettext with MS Visual C++?

Is it possible to use GNU gettext with MS Visual C++? Does someone know where to find a sample project that compiles under Visual C++? Update: Thanks to Sorin Sbarnea for his comments which help me to put all the pieces together: I'm used to the…
Name
  • 3,430
  • 4
  • 30
  • 34
6
votes
1 answer

How to translate a GTK+ app?

I want to translate my GTK+ application written in C++. I don not have any ideas where to start, I heard about gettext(), but I don't know, how should I use it.
poxip
  • 909
  • 8
  • 25
6
votes
5 answers

How to count empty translations in .po with grep (or other LSB tool)?

I can perform search of empty translations in vim with command like this: /""\n\n But my task is to find number of non-translated strings. Any ideas how to do this with standard tools which every linux box should have (no separate packages…
Sergey P. aka azure
  • 3,993
  • 1
  • 29
  • 23
6
votes
4 answers

Better to use multiple language files or 1?

From your experience, is it better to use 1 language file or multiple smaller langauge files for each language in a PHP project using the gettext extension? I am not even sure if it is possible to use multiple files, it is hard for me to test since…
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
6
votes
1 answer

Gettext without a filesystem

For an embedded system with GUI, we are using our custom translation system. The strings are stored in the code ROM of a microcontroller. Currently we have up to 10 languages and about 400 translated strings (varies depending on the product…
6
votes
1 answer

How to tell bash to get gettext .mo file from custom location?

I am creating a bash script for a very specific project, and the strings must be translatable. I have successfully followed the following tutorial: gettext support for bash scripts: http://mywiki.wooledge.org/BashFAQ/098 However, part of the…
augustin
  • 14,373
  • 13
  • 66
  • 79