summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-07-11 19:34:31 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-07-11 19:34:31 +0200
commit1291f49781fbb0dd3090c9f1ea6737bf334a515d (patch)
treeac92774e2a00872f37adc9903f29a5a69ac11e22
parentfixed settings (diff)
downloadpyload-1291f49781fbb0dd3090c9f1ea6737bf334a515d.tar.xz
use gettext/jed for webui translations
-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
-rw-r--r--pyload/web/app/templates/default/dashboard/select.html8
-rwxr-xr-xtests/hosterlinks.txt3
5 files changed, 31 insertions, 4 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
diff --git a/pyload/web/app/templates/default/dashboard/select.html b/pyload/web/app/templates/default/dashboard/select.html
index 3803bb646..f4c696d11 100644
--- a/pyload/web/app/templates/default/dashboard/select.html
+++ b/pyload/web/app/templates/default/dashboard/select.html
@@ -1,8 +1,8 @@
<i class="icon-check" data-toggle="tooltip" title="Deselect"></i>&nbsp;
-{{#if packs }}{{ packs }} package(s){{/if }}
-{{#if files }}
-{{#if packs }}, {{/if }}
-{{ files }} file(s)
+{{#if packs }}{{ ngettext "1 package" "%d packages" packs }}{{/if}}
+{{#if files}}
+{{#if packs}}, {{/if}}
+{{ ngettext "1 file" "%d files" files }}
{{/if }}
selected
&nbsp;|&nbsp;
diff --git a/tests/hosterlinks.txt b/tests/hosterlinks.txt
index 29331db8f..32418a66f 100755
--- a/tests/hosterlinks.txt
+++ b/tests/hosterlinks.txt
@@ -3,7 +3,10 @@
# Valid files, with md5 hash
[files]
+# Two variants of filename with special chars
+räándöóm.bin 5dde9e312311d964572f5a33a0992a2c
random (机会,ឱកស,ランダム,隨機,лчаный,cơhội,შანსი,కంħن↓∂ƒ_স€קสม®¢äöář_æžĐşiồй_ныứ&+).bin 5dde9e312311d964572f5a33a0992a2c
+
random100.bin f346c3ea47d8bfce3a12033129dec8ff
[online]