User Tools

Site Tools


proj:translation

Home

Project

Translation and i18n

Contact Kathrin.Seibt@mailbox.tu-dresden.de to help with German translation

Translation

Glossary

  • .pot: a template that includes the English text that you want people to translate. msgid and msgstr (all empty)
  • .po: translations for one language in a human-readable and editable form. A renamed copy of the pot file with (hopefully) most of the msgstr's filled in ;-)
  • .mo: a compiled binary form of a .po file.

Workflow

Whenever SOFA has lots of new strings:

  • Need to make new pot and po files for translators to work on
  • Need to get new mo files to include in packages

Making new pot and po files

  • Ensure all files in project (see bzr ls -V) are in app.fil
  • cd /home/g/projects/SOFA/sofastatistics/sofa.repo/sofa.main/
  • Run python mki18n.py -p to produce messages.pot.
  • Rename sofastats.pot as sofastats_YYYY-MM-DD.pot and store off tree in sofa/storage/translation.
  • Rename messages.pot to sofastats.pot.
  • Add sofastats.pot to Launchpad by uploading to the correct series (not trunk). OK not to use a tar.gz etc if just an individual file.
    • Select Series e.g. 1.3
    • Then select translations
    • Then click on “manually upload” link
    • Upload sofastats.pot
    • Keep an eye on the translation import queue
  • Old translations e.g. from series 0.9 are suggested but need to be accepted individually (is that only because the name changed from sofa to sofastats?).

New mo files

Don't make your own! Just use the ones from launchpad - they always work. Use the download link and select mo as output.

Import queue

Hello!

Launchpad Maintain your project's translation import queue


Whenever someone imports a new translation or template file into your project in Launchpad, that file gets reviewed to make sure it's correctly formatted.

Up until recently, the Launchpad team looked after those reviews. Now, you can review your project's translations import queue yourself.

To review your project's queue, follow the “import queue” link on your project's translations overview page.

When reviewing the queue, you're looking to make sure that the files are correctly named, that the file really is intended for your project and that templates contain only English strings. There's more in our guide here:

https://help.launchpad.net/Translations/YourProject/ImportingTemplates

Once you've manually approved a file, Launchpad will automatically approve any future updates to it.

If you need help, feel free to join us in #launchpad on FreeNode.

Thanks,

Matthew Revell and the Launchpad team.

http://blog.launchpad.net

Deprecated - Rolling your own mo's

The charset line at the top of a po file must be appropriate for the encoding.

:-\ If you don't match the file encoding to the alleged charset you get this sort of thing:

sofa_gl_ES.po:146:40: invalid multibyte sequence

msgfmt: too many errors, aborting

For Ubuntu, utf-8 will always work. In Windows, charset and encoding has to handled on a case-by-case basis. Different mo files will be required for Windows because it doesn't handle utf-8.

Windows Charset and encoding requirements
  • sofa_gl_ES.po - charset=ISO-8859-1
  • sofa_ru_RU.po - ?
Example
  • cd /home/g/projects/SOFA/sofastatistics/sofa.repo/sofa.main/
  • python mki18n.py -m
  • relabel /home/g/projects/SOFA/sofastatistics/sofa.repo/sofa.main/locale/gl_ES/LC_MESSAGES/sofa.mo to sofa_ub.mo (or sofa_win.mo as appropriate)

I Can Translate Into X

Thanks. Translation is pretty streamlined these days thanks to Launchpad. The place to go is https://translations.launchpad.net/sofastatistics. Near the bottom right click the link “View all languages”. If you have any questions, please do not hesitate to contact me. If you manage to translate a reasonable proportion of the English strings please let me know and I will add the <LANGUAGE NAME HERE> language pack to the installers.

Internationalisation

General

Unicode strings only (with escaped backslashes when dealing with Windows paths). We must assume that international characters will be stored in databases, variable lists, value labels, project names etc etc etc. Even a path could have a user name in it like René.

As long as all references to paths are stored as unicode e.g. u“C:\\Users\\john\\sofa …” we should be all right.

User-entered paths will need to be saved as unicode with escaped backslashes.

The database interface modules such as MySQLdb return unicode (NB in the case of MySQLdb, “use_unicode” must be explicitly set to True when setting up the connection).

All strings must be wrapped with _() so that they are exposed to translations.

Use unicode() rather than str().

Must be able to cope with Microsoft-derived, non-unicode text e.g. smart quotes pasted from Word or Excel using cp1252.

When reading from any user-editable text file, must cope with (i.e. strip off the start) the BOM if present. E.g. project files, variable details files, html report files, css files. The error you might get if you don't is “encoding declaration in Unicode string”.

Specific

project.GetProjSettings populates a dictionary from a text file using exec. It reads text like u“C:\\Users\…” successfully as unicode strings.

project.OnOK writes all the variables to the project file as text. The unicode strings are all written with a u“…” so that they will be read as unicode strings.

util.clean_bom_utf8 strips the BOM off the front of text that Notepad sticks on the front. TODO handle utf-16 and utf-32 better.

Right to Left Languages

Main Measures Taken in SOFA

Pre-reversed images so they are correct when the OS/toolkit reverses them again - wx.Image has a Mirror() method.

Shift some non-images from left to right or vice versa.

Alignment

Identifying current layout direction

def currentLanguageIsRightToLeft():
    return wx.GetApp().GetLayoutDirection() == wx.Layout_RightToLeft

http://wxpython-users.1045709.n5.nabble.com/Persian-Farsi-is-a-Right-to-Left-language-but-GUI-is-not-changed-td2374817.html

Setting the layout direction of individual windows (dialog and controls individually)

window.SetLayoutDirection(wx.Layout_RightToLeft))

Possible to set for all windows in the application at once?

wxApp.SetLayoutDirection(wx.Layout_RightToLeft) ?

http://wxpython-users.1045709.n5.nabble.com/Persian-Farsi-is-a-Right-to-Left-language-but-GUI-is-not-changed-td2374817.html

Drawn images

Adding items to sizers in reverse order

References

proj/translation.txt · Last modified: 2015/04/12 00:05 by admin