Fix translations in non standard prefix

This drops a lot of code at the same time. The code in
__init__ was:

* Using a SUGAR_PREFIX environment variable that is not
defined anywhere
* Hardcoding prefix to /usr
* Setting up the sugar-base domain which doesn't exist anymore

The i18n module code was overcomplex because it was thought
for language packs which we don't support anymore, it was
not handling correctly locales with a country prefix, it
was hard coding the python prefix and it was not sorting
the directories as it intended too anyway.

The logic is very simple now. Use the locale directory in
the same prefix sugar-toolkit-gtk3 was installed, unless
SUGAR_LOCALEDIR is defined (for self contained bundles).
This commit is contained in:
Daniel Narvaez
2013-09-10 22:42:48 +02:00
parent 4259cc4fd1
commit 9717e5954b
6 changed files with 30 additions and 85 deletions
+7 -5
View File
@@ -34,6 +34,7 @@ DBusGMainLoop(set_as_default=True)
from sugar3.activity import activityhandle
from sugar3.activity import i18n
from sugar3 import config
import sugar3
from sugar3.bundle.activitybundle import ActivityBundle
from sugar3 import logger
@@ -107,11 +108,12 @@ def main():
os.environ['SUGAR_BUNDLE_VERSION'] = str(bundle.get_activity_version())
# must be done early, some activities set translations globally, SL #3654
locale_path = i18n.get_locale_path(bundle.get_bundle_id())
if locale_path:
gettext.bindtextdomain(bundle.get_bundle_id(), locale_path)
gettext.bindtextdomain('sugar-toolkit', sugar3.locale_path)
gettext.textdomain(bundle.get_bundle_id())
activity_locale_path = os.environ.get("SUGAR_LOCALEDIR",
config.locale_path)
gettext.bindtextdomain(bundle.get_bundle_id(), activity_locale_path)
gettext.bindtextdomain('sugar-toolkit', config.locale_path)
gettext.textdomain(bundle.get_bundle_id())
splitted_module = args[0].rsplit('.', 1)
module_name = splitted_module[0]