Mercurial > pyntnclick
changeset 479:4ea237bbcef8 1.0.1
Tidy up the i18n changes
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Tue, 08 Mar 2011 13:25:20 +0200 |
parents | a9925aaf5f61 |
children | 7d8e4f2a5bbe |
files | README-i18n.txt gamelib/i18n.py gamelib/main.py gamelib/state.py install-po.sh update-po.sh |
diffstat | 6 files changed, 18 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/README-i18n.txt Tue Mar 08 12:29:14 2011 +0200 +++ b/README-i18n.txt Tue Mar 08 13:25:20 2011 +0200 @@ -17,11 +17,11 @@ this navigate to the `po/' directory in terminal and type command msginit -l <locale> - + where <locale> is two-letters-language-code you need. Then translate generated file using your preferred editor. -To get new translation worked you need to compile and install it by +To get new translation to work you need to compile and install it by executing `install-po.sh' script. @@ -29,14 +29,13 @@ Just surround it with _( and ) like "Hello, world" -> _("Hello, world!") - -_() is a function that I placed in `gamelib/i18n.py' file, so you -might want to import it first. + +_() is a function in `gamelib/i18n.py' file, so you might want to +import it first. from gamelib.i18n import _ And don't forget to update message catalogs with new strings. To do that just execute `update-po.sh' script. It collects all translatable -strings from files that are specified in `po/POTFILES'. Make sure file -you worked on is in there. - +strings from files that are specified in `po/POTFILES'. Make sure the +file you worked on is in there.
--- a/gamelib/i18n.py Tue Mar 08 12:29:14 2011 +0200 +++ b/gamelib/i18n.py Tue Mar 08 13:25:20 2011 +0200 @@ -3,4 +3,4 @@ from gettext import gettext def _(s): - return unicode(gettext(s), "utf-8") + return unicode(gettext(s), "utf-8")
--- a/gamelib/main.py Tue Mar 08 12:29:14 2011 +0200 +++ b/gamelib/main.py Tue Mar 08 13:25:20 2011 +0200 @@ -10,6 +10,8 @@ import os.path right_path = os.path.dirname(os.path.dirname(__file__)) sys.path.insert(0, right_path) +import gettext +import locale from optparse import OptionParser import pygame @@ -23,8 +25,6 @@ from sound import no_sound, disable_sound import state import data -from locale import setlocale, LC_ALL -from gettext import bindtextdomain, textdomain def parse_args(args): parser = OptionParser() @@ -65,9 +65,11 @@ # debug the specified scene state.DEBUG_SCENE = opts.scene state.DEBUG_RECTS = opts.rects - setlocale(LC_ALL, "") - bindtextdomain("suspended-sentence", data.filepath('locale')) - textdomain("suspended-sentence") + + locale.setlocale(locale.LC_ALL, "") + gettext.bindtextdomain("suspended-sentence", data.filepath('locale')) + gettext.textdomain("suspended-sentence") + display = pygame.display.set_mode(SCREEN, SWSURFACE) pygame.display.set_icon(pygame.image.load( data.filepath('icons/suspended_sentence24x24.png')))
--- a/gamelib/state.py Tue Mar 08 12:29:14 2011 +0200 +++ b/gamelib/state.py Tue Mar 08 13:25:20 2011 +0200 @@ -293,7 +293,7 @@ if text is None: return None label = BoomLabel(text) - font = get_font(15, 'VeraBd.ttf') + #font = get_font(15, 'DejaVuSans-Bold.ttf') label.set_margin(5) label.border_width = 1 label.border_color = (0, 0, 0)
--- a/install-po.sh Tue Mar 08 12:29:14 2011 +0200 +++ b/install-po.sh Tue Mar 08 13:25:20 2011 +0200 @@ -1,6 +1,6 @@ #!/bin/sh -#Compiles and installs translation catalogs +# Compiles and installs translation catalogs for pofile in po/*.po; do molang=`echo $pofile | sed -e 's#po/\(.*\)\\.po#\\1#'`;