Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine van Gelder <antoine@g7.org.za>2008-01-22 10:23:05 (GMT)
committer Antoine van Gelder <antoine@g7.org.za>2008-01-22 10:23:05 (GMT)
commit6a0d1b15d47d4cea711f63669636c6c3354c9e89 (patch)
tree80e736ceb12168b34f5b286f62e1dfcce4d40170
parent9bfa9a701d445395adec061bd38f82dd0babee80 (diff)
* i18n: Changed layout re ticket #6110
-rw-r--r--MANIFEST3
-rw-r--r--NEWS4
-rw-r--r--TODO1
-rw-r--r--gui/frame.py2
-rw-r--r--i18n.py65
-rw-r--r--locale/af/LC_MESSAGES/org.worldwideworkshop.olpc.JokeMachine.mo (renamed from po/af/LC_MESSAGES/JokeMachine.mo)bin2696 -> 2696 bytes
-rw-r--r--po/af.po (renamed from po/af/LC_MESSAGES/JokeMachine.po)0
7 files changed, 36 insertions, 39 deletions
diff --git a/MANIFEST b/MANIFEST
index 672900b..4a7985d 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -19,8 +19,7 @@
./lessons/Lesson 3/default.abw
./lessons/Lesson 4/default.abw
./po/JokeMachine.pot
-./po/af/LC_MESSAGES/JokeMachine.mo
-./po/af/LC_MESSAGES/JokeMachine.po
+./po/af.po
./mesh/__init__.py
./mesh/activitysession.py
./pages/__init__.py
diff --git a/NEWS b/NEWS
index bf31ba5..79ab329 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
-7
+ * i18n: Changed layout re ticket #6110
+
+JokeMachine-7.xo
* Updated: Expanded copyright header on source files
* Updated: Reflect changes in sugar.graphics.objectchooser
diff --git a/TODO b/TODO
index 076d749..9b6207d 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-
= To Do =
* Figure out why only alerts are being translated
diff --git a/gui/frame.py b/gui/frame.py
index 8a16fe8..0d04610 100644
--- a/gui/frame.py
+++ b/gui/frame.py
@@ -105,7 +105,7 @@ class Frame(hippo.Canvas):
padding_right=100,
yalign=hippo.ALIGNMENT_CENTER,
orientation=hippo.ORIENTATION_VERTICAL)
- button = LanguageComboBox()
+ button = LanguageComboBox('org.worldwideworkshop.olpc.JokeMachine')
button.install()
button.set_name('fubar')
language.props.widget = button
diff --git a/i18n.py b/i18n.py
index ea6d687..963d258 100644
--- a/i18n.py
+++ b/i18n.py
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright 2007 World Wide Workshop Foundation
-#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -17,14 +15,18 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
-# If you find this activity useful or end up using parts of it in one of your
-# own creations we would love to hear from you at info@WorldWideWorkshop.org !
-#
+
+
+### i18n.py
+### TODO: Describe
+### $Id: $
+###
+### author: Carlos Neves (cn (at) sueste.net)
+### (c) 2007 World Wide Workshop Foundation
import os
import gettext
import locale
-import logging
import gtk, gobject
@@ -39,7 +41,6 @@ lang_name_mapping = {
'cs':(None, _('Czech'),'czech_republic'),
'da':(None, _('Danish'),'denmark'),
'nl':(None, _('Dutch'), 'netherlands'),
- 'af':(None, _('Afrikaans'), 'south_africa'),
'en':('English', _('English'),'united_states'),
'en_gb':('English', _('English - Great Britain'),'united_kingdom'),
'en_us':('English', _('English - U.S.'),'united_states'),
@@ -59,17 +60,19 @@ lang_name_mapping = {
'es':('EspaƱol', _('Spanish'),'spain'),
'sv':(None, _('Swedish'),'sweden'),
'tr':(None, _('Turkish'),'turkey'),
+ 'af':(None, _('Afrikaans'), 'south_africa'),
}
class LangDetails (object):
- def __init__ (self, code, name, image):
+ def __init__ (self, code, name, image, domain):
self.code = code
self.country_code = self.code.split('_')[0]
self.name = name
self.image = image
+ self.domain = domain
def guess_translation (self, fallback=False):
- self.gnutranslation = gettext.translation('JokeMachine', './po', [self.code], fallback=fallback)
+ self.gnutranslation = gettext.translation(self.domain, 'locale', [self.code], fallback=fallback)
def install (self):
self.gnutranslation.install()
@@ -79,7 +82,7 @@ class LangDetails (object):
return code.lower() == self.code.lower()
return code.split('_')[0].lower() == self.country_code.lower()
-def get_lang_details (lang):
+def get_lang_details (lang, domain):
mapping = lang_name_mapping.get(lang.lower(), None)
if mapping is None:
# Try just the country code
@@ -88,15 +91,17 @@ def get_lang_details (lang):
if mapping is None:
return None
if mapping[0] is None:
- return LangDetails(lang, mapping[1], mapping[2])
- return LangDetails(lang, mapping[0], mapping[2])
+ return LangDetails(lang, mapping[1], mapping[2], domain)
+ return LangDetails(lang, mapping[0], mapping[2], domain)
-def list_available_translations ():
- rv = [get_lang_details('en')]
+def list_available_translations (domain):
+ rv = [get_lang_details('en', domain)]
rv[0].guess_translation(True)
- for i,x in enumerate([x for x in os.listdir('po') if os.path.isdir('po/' + x) and not x.startswith('.')]):
+ if not os.path.isdir('locale'):
+ return rv
+ for i,x in enumerate([x for x in os.listdir('locale') if os.path.isdir('locale/' + x) and not x.startswith('.')]):
try:
- details = get_lang_details(x)
+ details = get_lang_details(x, domain)
if details is not None:
details.guess_translation()
rv.append(details)
@@ -106,7 +111,7 @@ def list_available_translations ():
return rv
class LanguageComboBox (gtk.ComboBox):
- def __init__ (self):
+ def __init__ (self, domain):
liststore = gtk.ListStore(gobject.TYPE_STRING)
gtk.ComboBox.__init__(self, liststore)
@@ -114,7 +119,7 @@ class LanguageComboBox (gtk.ComboBox):
self.pack_start(self.cell, True)
self.add_attribute(self.cell, 'text', 0)
- self.translations = list_available_translations()
+ self.translations = list_available_translations(domain)
for i,x in enumerate(self.translations):
liststore.insert(i+1, (gettext.gettext(x.name), ))
self.connect('changed', self.install)
@@ -125,19 +130,11 @@ class LanguageComboBox (gtk.ComboBox):
def install (self, *args):
if self.get_active() > -1:
- translation = self.translations[self.get_active()]
- logging.debug('i18n - Installing locale: %r %r - %r',
- translation.code,
- translation.country_code,
- translation.name)
- translation.install()
+ self.translations[self.get_active()].install()
else:
code, encoding = locale.getdefaultlocale()
- logging.debug('Locale code: %r' % code)
if code is None:
- locale.setlocale(locale.LC_ALL, 'en_US')
- code, encoding = locale.getlocale()
-
+ code = 'en'
# Try to find the exact translation
for i,t in enumerate(self.translations):
if t.matches(code):
@@ -158,13 +155,13 @@ class LanguageComboBox (gtk.ComboBox):
###
def gather_other_translations ():
from glob import glob
- entries = filter(lambda x: os.path.isdir(x), glob('images/*'))
- entries.extend(filter(lambda x: os.path.isdir(x), glob('lessons/*')))
- entries = map(lambda x: os.path.basename(x), entries)
+ lessons = filter(lambda x: os.path.isdir(x), glob('lessons/*'))
+ lessons = map(lambda x: os.path.basename(x), lessons)
+ lessons = map(lambda x: x[0].isdigit() and x[1:] or x, lessons)
+ images = filter(lambda x: os.path.isdir(x), glob('images/*'))
+ images = map(lambda x: os.path.basename(x), images)
f = file('i18n_misc_strings.py', 'w')
- for e in entries:
+ for e in images+lessons:
f.write('_("%s")\n' % e)
f.close()
-if __name__ == '__main__':
- gather_other_translations()
diff --git a/po/af/LC_MESSAGES/JokeMachine.mo b/locale/af/LC_MESSAGES/org.worldwideworkshop.olpc.JokeMachine.mo
index f2a2854..f2a2854 100644
--- a/po/af/LC_MESSAGES/JokeMachine.mo
+++ b/locale/af/LC_MESSAGES/org.worldwideworkshop.olpc.JokeMachine.mo
Binary files differ
diff --git a/po/af/LC_MESSAGES/JokeMachine.po b/po/af.po
index bccd5e5..bccd5e5 100644
--- a/po/af/LC_MESSAGES/JokeMachine.po
+++ b/po/af.po