Create table entries for plural forms and lookup them.

This commit is contained in:
Yak! 2013-07-13 14:09:19 +09:00
parent 7a7a0dc2dd
commit da07af65d5
1 changed files with 9 additions and 4 deletions

View File

@ -4270,18 +4270,23 @@
} }
function ngettext(msg1, msg2, n) { function ngettext(msg1, msg2, n) {
return (parseInt(n) > 1) ? msg2 : msg1; return __((parseInt(n) > 1) ? msg2 : msg1);
}'; }';
$l10n = _get_reader(); $l10n = _get_reader();
for ($i = 0; $i < $l10n->total; $i++) { for ($i = 0; $i < $l10n->total; $i++) {
$orig = $l10n->get_original_string($i); $orig = $l10n->get_original_string($i);
if(strpos($orig, "\000") !== FALSE) { // Plural forms
$key = explode(chr(0), $orig);
print T_js_decl($key[0], ngettext($key[0], $key[1], 1)); // Singular
print T_js_decl($key[1], ngettext($key[0], $key[1], 2)); // Plural
} else {
$translation = __($orig); $translation = __($orig);
print T_js_decl($orig, $translation); print T_js_decl($orig, $translation);
} }
} }
}
function label_to_feed_id($label) { function label_to_feed_id($label) {
return LABEL_BASE_INDEX - 1 - abs($label); return LABEL_BASE_INDEX - 1 - abs($label);