diff --git a/Makefile b/Makefile index b24f30bf57..a98c1538f5 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ develop: setup-git setup-git: cd .git/hooks && ln -sf ../../hooks/* ./ -dist: locale uglify statici18n collectstatic compressstatic +dist: locale uglify statici18n collectstatic locale: @echo "--> Compile locales" diff --git a/static/scripts/i18n/zh-cn/djangojs.js b/static/scripts/i18n/zh-cn/djangojs.js index cf592a306e..f35fbba26f 100644 --- a/static/scripts/i18n/zh-cn/djangojs.js +++ b/static/scripts/i18n/zh-cn/djangojs.js @@ -5,17 +5,58 @@ var django = globals.django || (globals.django = {}); - django.pluralidx = function (count) { return (count == 1) ? 0 : 1; }; + django.pluralidx = function (n) { + var v=0; + if (typeof(v) == 'boolean') { + return v ? 1 : 0; + } else { + return v; + } + }; - /* gettext identity library */ + /* gettext library */ + + django.catalog = { + "Really want to delete {lib_name}?": "\u786e\u5b9a\u8981\u5220\u9664 {lib_name} ?" + }; + + django.gettext = function (msgid) { + var value = django.catalog[msgid]; + if (typeof(value) == 'undefined') { + return msgid; + } else { + return (typeof(value) == 'string') ? value : value[0]; + } + }; + + django.ngettext = function (singular, plural, count) { + var value = django.catalog[singular]; + if (typeof(value) == 'undefined') { + return (count == 1) ? singular : plural; + } else { + return value[django.pluralidx(count)]; + } + }; - django.gettext = function (msgid) { return msgid; }; - django.ngettext = function (singular, plural, count) { return (count == 1) ? singular : plural; }; django.gettext_noop = function (msgid) { return msgid; }; - django.pgettext = function (context, msgid) { return msgid; }; - django.npgettext = function (context, singular, plural, count) { return (count == 1) ? singular : plural; }; + + django.pgettext = function (context, msgid) { + var value = django.gettext(context + '\x04' + msgid); + if (value.indexOf('\x04') != -1) { + value = msgid; + } + return value; + }; + + django.npgettext = function (context, singular, plural, count) { + var value = django.ngettext(context + '\x04' + singular, context + '\x04' + plural, count); + if (value.indexOf('\x04') != -1) { + value = django.ngettext(singular, plural, count); + } + return value; + }; django.interpolate = function (fmt, obj, named) {