Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/frame.py18
-rw-r--r--gui/lessonplanwidget.py1
-rw-r--r--i18n.py171
-rw-r--r--i18n_misc_strings.py5
4 files changed, 1 insertions, 194 deletions
diff --git a/gui/frame.py b/gui/frame.py
index aa54312..49a5a8e 100644
--- a/gui/frame.py
+++ b/gui/frame.py
@@ -23,7 +23,6 @@ import gtk
import hippo
import logging
-from i18n import LanguageComboBox
from gettext import gettext as _
from globals import Globals
@@ -92,23 +91,6 @@ class Frame(hippo.Canvas):
logo.set_from_file(Globals.logo)
ret.append(hippo.CanvasWidget(widget=logo))
- # language selection box
- language = hippo.CanvasWidget(background_color=theme.COLOR_BACKGROUND.get_int(),
- border_top=theme.BORDER_WIDTH,
- border_left=theme.BORDER_WIDTH,
- border_color=theme.COLOR_FRAME.get_int(),
- padding_top=12,
- padding_bottom=12,
- padding_left=100,
- padding_right=100,
- yalign=hippo.ALIGNMENT_CENTER,
- orientation=hippo.ORIENTATION_VERTICAL)
- button = LanguageComboBox('org.worldwideworkshop.JokeMachineActivity')
- button.install()
- button.set_name('fubar')
- language.props.widget = button
- ret.append(language, hippo.PACK_EXPAND)
-
# lesson plans
lesson_plans = hippo.CanvasWidget(background_color=theme.COLOR_BACKGROUND.get_int(),
border_top=theme.BORDER_WIDTH,
diff --git a/gui/lessonplanwidget.py b/gui/lessonplanwidget.py
index 3d4a100..98c90ce 100644
--- a/gui/lessonplanwidget.py
+++ b/gui/lessonplanwidget.py
@@ -22,6 +22,7 @@ import os
import locale
import gtk
import logging
+from gettext import gettext as _
from abiword import Canvas as AbiCanvas
diff --git a/i18n.py b/i18n.py
deleted file mode 100644
index 9e8779b..0000000
--- a/i18n.py
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# 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
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-
-### 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 gtk, gobject
-
-_ = lambda x: x
-
-# Images were taken from http://www.sodipodi.com/
-# except for korea taken from http://zh.wikipedia.org/wiki/Image:Unification_flag_of_Korea.svg
-
-lang_name_mapping = {
- 'zh_cn':(None, _('Chinese (simplified)'), 'china'),
- 'zh_tw':(None, _('Chinese (traditional)'), 'china'),
- 'cs':(None, _('Czech'),'czech_republic'),
- 'da':(None, _('Danish'),'denmark'),
- 'nl':(None, _('Dutch'), 'netherlands'),
- 'en':('English', _('English'),'united_states'),
- 'en_gb':('English', _('English - Great Britain'),'united_kingdom'),
- 'en_us':('English', _('English - U.S.'),'united_states'),
- 'fi':(None, _('Finnish'),'finland'),
- 'fr':('Français', _('French'),'france'),
- 'de':(None, _('German'),'germany'),
- 'hu':(None, _('Hungarian'),'hungary'),
- 'it':(None, _('Italian'),'italy'),
- 'ja':(None, _('Japanese'),'japan'),
- 'ko':(None, _('Korean'),'korea'),
- 'no':(None, _('Norwegian'),'norway'),
- 'pl':(None, _('Polish'),'poland'),
- 'pt':('Português', _('Portuguese'),'portugal'),
- 'pt_br':('Português do Brasil', _('Portuguese - Brazilian'),'brazil'),
- 'ru':(None, _('Russian'),'russian_federation'),
- 'sk':(None, _('Slovak'),'slovenia'),
- '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, 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):
- try:
- self.gnutranslation = gettext.translation(self.domain, 'locale', [self.code], fallback=fallback)
- return True
- except:
- return False
-
- def install (self):
- self.gnutranslation.install()
-
- def matches (self, code, exact=True):
- if exact:
- return code.lower() == self.code.lower()
- return code.split('_')[0].lower() == self.country_code.lower()
-
-def get_lang_details (lang, domain):
- mapping = lang_name_mapping.get(lang.lower(), None)
- if mapping is None:
- # Try just the country code
- lang = lang.split('_')[0]
- mapping = lang_name_mapping.get(lang.lower(), None)
- if mapping is None:
- return None
- if mapping[0] is None:
- return LangDetails(lang, mapping[1], mapping[2], domain)
- return LangDetails(lang, mapping[0], mapping[2], domain)
-
-def list_available_translations (domain):
- rv = [get_lang_details('en', domain)]
- rv[0].guess_translation(True)
- 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, domain)
- if details is not None:
- if details.guess_translation():
- rv.append(details)
- except:
- raise
- pass
- return rv
-
-class LanguageComboBox (gtk.ComboBox):
- def __init__ (self, domain):
- liststore = gtk.ListStore(gobject.TYPE_STRING)
- gtk.ComboBox.__init__(self, liststore)
-
- self.cell = gtk.CellRendererText()
- self.pack_start(self.cell, True)
- self.add_attribute(self.cell, 'text', 0)
-
- 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)
-
- def modify_bg (self, state, color):
- setattr(self.cell, 'background-gdk',color)
- setattr(self.cell, 'background-set',True)
-
- def install (self, *args):
- if self.get_active() > -1:
- self.translations[self.get_active()].install()
- else:
- code, encoding = locale.getdefaultlocale()
- if code is None:
- code = 'en'
- # Try to find the exact translation
- for i,t in enumerate(self.translations):
- if t.matches(code):
- self.set_active(i)
- break
- if self.get_active() < 0:
- # Failed, try to get the translation based only in the country
- for i,t in enumerate(self.translations):
- if t.matches(code, False):
- self.set_active(i)
- break
- if self.get_active() < 0:
- # nothing found, select first translation
- self.set_active(0)
- # Allow for other callbacks
- return False
-
-###
-def gather_other_translations ():
- from glob import glob
- 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 images+lessons:
- f.write('_("%s")\n' % e)
- f.close()
-
diff --git a/i18n_misc_strings.py b/i18n_misc_strings.py
deleted file mode 100644
index d31a70e..0000000
--- a/i18n_misc_strings.py
+++ /dev/null
@@ -1,5 +0,0 @@
-_("Lesson 1")
-_("Lesson 2")
-_("Lesson 3")
-_("Lesson 4")
-_("Introduction")