summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts')
-rw-r--r--pyload/web/app/scripts/config.js3
-rw-r--r--pyload/web/app/scripts/helpers/gettext.js16
-rw-r--r--pyload/web/app/scripts/utils/i18n.js5
3 files changed, 24 insertions, 0 deletions
diff --git a/pyload/web/app/scripts/config.js b/pyload/web/app/scripts/config.js
index f2af39c56..9d1d027d9 100644
--- a/pyload/web/app/scripts/config.js
+++ b/pyload/web/app/scripts/config.js
@@ -36,6 +36,9 @@ require.config({
disableI18n: true,
helperPathCallback: // Callback to determine the path to look for helpers
function(name) {
+ if (name === '_' || name === 'ngettext')
+ name = 'gettext';
+
// Some helpers are accumulated into one file
if (name.indexOf('file') === 0)
name = 'fileHelper';
diff --git a/pyload/web/app/scripts/helpers/gettext.js b/pyload/web/app/scripts/helpers/gettext.js
new file mode 100644
index 000000000..d73b5e378
--- /dev/null
+++ b/pyload/web/app/scripts/helpers/gettext.js
@@ -0,0 +1,16 @@
+require(['underscore', 'handlebars', 'utils/i18n'], function(_, Handlebars, i18n) {
+ 'use strict';
+ // These methods binds additional content directly to translated message
+ function ngettext(single, plural, n) {
+ return i18n.sprintf(i18n.ngettext(single, plural, n), n);
+ }
+
+ function gettext(key, message) {
+ return i18n.sprintf(i18n.gettext(key), message);
+ }
+
+ Handlebars.registerHelper('_', gettext);
+ Handlebars.registerHelper('gettext', gettext);
+ Handlebars.registerHelper('ngettext', ngettext);
+ return gettext;
+}); \ No newline at end of file
diff --git a/pyload/web/app/scripts/utils/i18n.js b/pyload/web/app/scripts/utils/i18n.js
new file mode 100644
index 000000000..a8d948b4a
--- /dev/null
+++ b/pyload/web/app/scripts/utils/i18n.js
@@ -0,0 +1,5 @@
+define(['jed'], function(Jed) {
+ 'use strict';
+ // TODO load i18n data
+ return new Jed({});
+}); \ No newline at end of file