From 56b10fea1805b4ff0e7129adb8216d4d89b74147 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 26 Feb 2021 09:21:17 +0300 Subject: pass translations to frontend as a json object --- js/App.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'js/App.js') diff --git a/js/App.js b/js/App.js index 67d932369..bb8da578d 100644 --- a/js/App.js +++ b/js/App.js @@ -17,6 +17,15 @@ const App = { hotkey_actions: {}, is_prefs: false, LABEL_BASE_INDEX: -1024, + _translations: {}, + l10n: { + ngettext: function(msg1, msg2, n) { + return self.__((parseInt(n) > 1) ? msg2 : msg1); + }, + __: function(msg) { + return App._translations[msg] ? App._translations[msg] : msg; + } + }, FormFields: { attributes_to_string: function(attributes) { return Object.keys(attributes).map((k) => @@ -525,6 +534,13 @@ const App = { PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, this._initParams); } + const translations = reply['translations']; + + if (translations) { + console.log('reading translations...'); + App._translations = translations; + } + this.initSecondStage(); }, Error: { -- cgit v1.2.3