diff --git a/core/modules/pluginswitcher.js b/core/modules/pluginswitcher.js index 9c05d375f..ab82be933 100644 --- a/core/modules/pluginswitcher.js +++ b/core/modules/pluginswitcher.js @@ -18,12 +18,14 @@ wiki: wiki store to be used pluginType: type of plugin to be switched controllerTitle: title of tiddler used to control switching of this resource defaultPlugins: array of default plugins to be used if nominated plugin isn't found +onSwitch: callback when plugin is switched (single parameter is array of plugin titles) */ function PluginSwitcher(options) { this.wiki = options.wiki; this.pluginType = options.pluginType; this.controllerTitle = options.controllerTitle; this.defaultPlugins = options.defaultPlugins || []; + this.onSwitch = options.onSwitch; // Switch to the current plugin this.switchPlugins(); // Listen for changes to the selected plugin @@ -64,6 +66,10 @@ PluginSwitcher.prototype.switchPlugins = function() { var registeredTiddlers = $tw.wiki.registerPluginTiddlers(this.pluginType,plugins); // Unpack the current theme tiddlers $tw.wiki.unpackPluginTiddlers(); + // Call the switch handler + if(this.onSwitch) { + this.onSwitch(plugins); + } }; exports.PluginSwitcher = PluginSwitcher; diff --git a/core/modules/startup/startup.js b/core/modules/startup/startup.js index 427e7414f..3c310e593 100755 --- a/core/modules/startup/startup.js +++ b/core/modules/startup/startup.js @@ -63,7 +63,18 @@ exports.startup = function() { controllerTitle: "$:/language", defaultPlugins: [ "$:/languages/en-US" - ] + ], + onSwitch: function(plugins) { + if($tw.browser) { + console.log("switching language",plugins) + var pluginTiddler = $tw.wiki.getTiddler(plugins[0]); + if(pluginTiddler) { + document.documentElement.setAttribute("dir",pluginTiddler.getFieldString("text-direction") || "auto"); + } else { + document.documentElement.removeAttribute("dir"); + } + } + } }); // Kick off the theme manager $tw.themeManager = new $tw.PluginSwitcher({ diff --git a/languages/he-IL/plugin.info b/languages/he-IL/plugin.info index fa2b8f52f..61e6be6cd 100644 --- a/languages/he-IL/plugin.info +++ b/languages/he-IL/plugin.info @@ -4,5 +4,6 @@ "plugin-type": "language", "description": "Hebrew (Israel)", "author": "DoronTzur", - "core-version": ">=5.0.0" + "core-version": ">=5.0.0", + "text-direction": "rtl" } \ No newline at end of file diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index abebaf593..04ad51a9f 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -690,6 +690,11 @@ button.tc-untagged-label { padding: 71px 0 28px 42px; } + html[dir="rtl"] .tc-sidebar-scrollable { + left: auto; + right: {{$:/themes/tiddlywiki/vanilla/metrics/storyright}}; + } + .tc-story-river { position: relative; left: {{$:/themes/tiddlywiki/vanilla/metrics/storyleft}};