diff options
author | Kalpa Welivitigoda <callkalpa@gmail.com> | 2013-08-20 04:00:09 (GMT) |
---|---|---|
committer | Kalpa Welivitigoda <callkalpa@gmail.com> | 2013-08-20 04:00:09 (GMT) |
commit | 5b9f1e0769472478581a0bae39c3822e7f741208 (patch) | |
tree | 4881f862d5435d2a8216d06d3253c0230113ba1c | |
parent | 5d2eda643c4db77f77f0cc9bf3e1547bdc1b6a96 (diff) |
supports viewing translated contentactivity_help
-rwxr-xr-x | helpactivity.py | 15 |
1 files changed, 12 insertions, 3 deletions
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() |