Welcome to Translation with context

Translation with context

By Mark Overmeer (‎markov‎) from Arnhem.pm, Amsterdam.pm
Date: Friday, 22 August 2014 12:00
Duration: 20 minutes
Target audience: Any
Language: English


The GNU gettext system is commonly used as management framework for translating text. The strings in the program are called 'msgid'. PO (and MO) tables are created per language, linking those msgids to the text to be displayed for that language.

One of the complications of translations, is that values may need to be filled-in. The order of these inserted texts may depend on the languages. This means that you usually have to play with formatted print.

One thing that GNU gettext is not able to handle, is that the inserted values may influence the whole translation. For instance, when a person's name is inserted, the sentence might need to either use the she or the he form. English is a relatively easy language in this respect, but many languages are not so forgiving.

Log::Report::Translate::Context uses the msgctxt field of standard PO-files to make this very simple. Little information is added to msgids, to make context sensitive translations possible. Example of use:

print __x"{name<gender} forgot his bag", name => $name;

In this case, the insert of the name parameter links to the 'gender' setting in the context, which influences the PO record to be used. Come to the talk to see how easy this works.


Attended by: Jean Forget, Michael Lush, osfameron, Anton Berezin (‎Grrrr‎), Søren Lund (‎slu‎), Steffen Winkler (‎STEFFENW‎), Roman Daniel (‎wayan‎), Alex Balhatchet (‎Kaoru‎), Anatoliy Dmytriyev (‎tolid‎), Красимир Беров (‎berov‎), Ovidiu Satmari (‎ovidiu.satmari‎), Tudor Constantin, Jean-Baptiste Mazon, Mihai Pop, Dumitru Negrea, Dmitry Yaskolko (‎sotona‎), Marc Egea i Sala (‎meis‎), Andrew Nugged (nugged), Pavel Scherbinin (‎Dzirtik‎), Paul Cochrane (‎ptc‎), Upasana Shukla (‎upasana‎), Mihai Safta (‎SDCM‎), Oliver Hoos, Kamen Naydenov (‎pau4o‎), Thomas Reifenberger, Alex-P. Natsios (‎Drakevr‎), Manol Roujinov, Zlatin Stanimirov, Anca Davidel, Oana Raluca Rusu, ignat ignatov, Ivan Ivanov (‎suricactus‎), Jan Kittler (‎Kita‎), Vladimir Vasilev, Mihaela Marinca,