Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am really struggling with this language issue.

I went to System->Administration->Language Support and moved Turkish (Türkçe) to the top. Then I clicked "Apply System-wide" and restarted.

However, after restarting, echo $LANG reported en_US.utf8, so I logged out and back in - and now it reports tr_CY.utf8.

Now here's the problem:

  • I have a file 'xxx.po' in /usr/share/locale/tr_CY/LC_MESSAGES
  • I run the following Python code:

    import gettext
    
    
    gettext.bindtextdomain("xxx","/usr/share/locale")
    gettext.textdomain("xxx")
    tr = gettext.translation("xxx",
                             "/usr/share/locale",
                             ["tr_CY"],
                             fallback=True)
    
    
    print tr.gettext("sample")
    

Although 'sample' should be translated, it isn't.

What am I doing wrong?

share|improve this question
    
That tr_CY (means Cypriot Turkish) has nothing to do with even a few hundred thousand Turk living in Cyprus. It should be tr_TR . Maybe after this modification, it works. Even if it works or not after modification, tr_CY is wrong, it should be tr_TR . –  marenostrum Nov 6 '10 at 21:56
add comment

1 Answer

up vote 3 down vote accepted

I have a file 'xxx.po' in /usr/share/locale/tr_CY/LC_MESSAGES

The files in /usr/share/locale/<LANG>/LC_MESSAGES need to be in a binary format ('.mo' extension).

You achieve that by running msgfmt on the '.po' file:

msgfmt -c -v -o OUTPUT.mo LANG.po

  • -c checks the po file format,
  • -v is for detailed output,
  • -o OUTPUT.mo specifies the output file, where OUTPUT should be the name you used in 'bindtextdomain' and 'textdomain',
  • LANG.po the translation file.
share|improve this answer
    
Thanks! Worked like a charm! –  Nathan Osman Nov 6 '10 at 22:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.