Hi All,
i want to write simple code for localization in python
# main.py
import os.path, sys
import gettext
appname = "main"
dir = "./locale"
gettext.install(appname, dir, unicode=True)
languages = {
"german" : gettext.translation(appname, dir, languages=["de"]),
}
# Switch to German
languages["german"].install()
print _("This is a second message that should be in German")
to create a pot file i used the fallowing cmd.
C:\>Python26\Tools\i18n\pygettext -o main_de.pot main.py
it created po or pot file.
i edited .po file like this
#: main.py:16
msgid "This is a second message that should be in German"
msgstr "Grüß Gott"
to create .mo file i used
C:\>Python26\Tools\i18n\msgfmt -o main_de.mo main_de.po
it created .mo file also
later i run my main.py from cmd prompt to see the output
but i am getting error like this
C:\>main.py
Traceback (most recent call last):
File "C:\main.py", line 10, in <module>
"german" : gettext.translation(appname, dir, languages=["de"]),
File "C:\Python26\lib\gettext.py", line 469, in translation
raise IOError(ENOENT, 'No translation file found for domain',
domain)
IOError: [Errno 2] No translation file found for domain: 'main'
can anybody help me.
why iam not able ot translate.