From 5b9f1e0769472478581a0bae39c3822e7f741208 Mon Sep 17 00:00:00 2001 From: Kalpa Welivitigoda Date: Tue, 20 Aug 2013 04:00:09 +0000 Subject: supports viewing translated content --- diff --git a/helpactivity.py b/helpactivity.py index 4d7013d..88f5330 100755 --- a/helpactivity.py +++ b/helpactivity.py @@ -28,8 +28,6 @@ from sugar3.activity.widgets import StopButton from viewtoolbar import ViewToolbar -HOME = 'file://' + os.path.join(activity.get_bundle_path(), - 'help/index.html') class HelpActivity(activity.Activity): @@ -104,7 +102,7 @@ class HelpActivity(activity.Activity): self.set_canvas(_scrolled_window) self._web_view.show() self._web_view.load_uri(HOME) - + class Toolbar(Gtk.Toolbar): def __init__(self, web_view): @@ -152,3 +150,14 @@ class Toolbar(Gtk.Toolbar): def _go_home_cb(self, button): self._web_view.load_uri(HOME) + +# get index.html in the current language +def get_index_path(): + locale = os.environ.get('LANG') + language = locale.split('.')[0].split('_')[0].lower() + path = os.path.join(activity.get_bundle_path(),'help/' + language + '/index.html') + if not os.path.isfile(path): + path = os.path.join(activity.get_bundle_path(),'help/en/index.html') + return 'file://' + path + +HOME = get_index_path() -- cgit v0.9.1