Merge branch 'patch-14' into 'dev'
Add date/time plurals translation in JavaScript See merge request hubzilla/core!1336 (cherry picked from commita2575059e2
)5c0d3187
Add date/time plurals translation in JavaScript729d0d53
Update language.phpf68674b3
Update js_strings.tpl3ac4337a
Update main.jse96e3dc6
Update po2php.php54bdf59d
Update js_strings.php
This commit is contained in:
parent
5310f4e310
commit
eaee27c9e4
@ -38,6 +38,15 @@ function js_strings() {
|
|||||||
// using the defaults set below if left untranslated, empty strings if
|
// using the defaults set below if left untranslated, empty strings if
|
||||||
// translated to "NONE" and the corresponding language strings
|
// translated to "NONE" and the corresponding language strings
|
||||||
// if translated to anything else
|
// if translated to anything else
|
||||||
|
'minutes' => tt('%d minutes', '%d minutes', '%d'),
|
||||||
|
'hours' => tt('about %d hours', 'about %d hours', '%d'),
|
||||||
|
'days' => tt('%d days', '%d days', '%d'),
|
||||||
|
'months' => tt('%d months', '%d months', '%d'),
|
||||||
|
'years' => tt('%d years', '%d years', '%d'),
|
||||||
|
|
||||||
|
// get plural function code
|
||||||
|
'plural_func' => tf(),
|
||||||
|
|
||||||
'$t01' => ((t('timeago.prefixAgo') == 'timeago.prefixAgo') ? '' : ((t('timeago.prefixAgo') == 'NONE') ? '' : t('timeago.prefixAgo'))),
|
'$t01' => ((t('timeago.prefixAgo') == 'timeago.prefixAgo') ? '' : ((t('timeago.prefixAgo') == 'NONE') ? '' : t('timeago.prefixAgo'))),
|
||||||
'$t02' => ((t('timeago.prefixFromNow') == 'timeago.prefixFromNow') ? '' : ((t('timeago.prefixFromNow') == 'NONE') ? '' : t('timeago.prefixFromNow'))),
|
'$t02' => ((t('timeago.prefixFromNow') == 'timeago.prefixFromNow') ? '' : ((t('timeago.prefixFromNow') == 'NONE') ? '' : t('timeago.prefixFromNow'))),
|
||||||
'$t03' => ((t('timeago.suffixAgo') == 'timeago.suffixAgo') ? 'ago' : ((t('timeago.suffixAgo') == 'NONE') ? '' : t('timeago.suffixAgo'))),
|
'$t03' => ((t('timeago.suffixAgo') == 'timeago.suffixAgo') ? 'ago' : ((t('timeago.suffixAgo') == 'NONE') ? '' : t('timeago.suffixAgo'))),
|
||||||
@ -46,15 +55,15 @@ function js_strings() {
|
|||||||
// translatable main strings for jquery.timeago
|
// translatable main strings for jquery.timeago
|
||||||
'$t05' => t('less than a minute'),
|
'$t05' => t('less than a minute'),
|
||||||
'$t06' => t('about a minute'),
|
'$t06' => t('about a minute'),
|
||||||
'$t07' => t('%d minutes'),
|
'$t07' => ta('%d minutes'),
|
||||||
'$t08' => t('about an hour'),
|
'$t08' => t('about an hour'),
|
||||||
'$t09' => t('about %d hours'),
|
'$t09' => ta('about %d hours'),
|
||||||
'$t10' => t('a day'),
|
'$t10' => t('a day'),
|
||||||
'$t11' => t('%d days'),
|
'$t11' => ta('%d days'),
|
||||||
'$t12' => t('about a month'),
|
'$t12' => t('about a month'),
|
||||||
'$t13' => t('%d months'),
|
'$t13' => ta('%d months'),
|
||||||
'$t14' => t('about a year'),
|
'$t14' => t('about a year'),
|
||||||
'$t15' => t('%d years'),
|
'$t15' => ta('%d years'),
|
||||||
'$t16' => t(' '), // wordSeparator
|
'$t16' => t(' '), // wordSeparator
|
||||||
'$t17' => ((t('timeago.numbers') != 'timeago.numbers') ? t('timeago.numbers') : '[]'),
|
'$t17' => ((t('timeago.numbers') != 'timeago.numbers') ? t('timeago.numbers') : '[]'),
|
||||||
|
|
||||||
|
@ -254,6 +254,32 @@ function tt($singular, $plural, $count, $ctx = ''){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return slash separated string of plurals translation forms
|
||||||
|
*
|
||||||
|
* @param string $k key in translations array
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function ta($k){
|
||||||
|
|
||||||
|
$t = App::$strings[$k];
|
||||||
|
if (is_array($t))
|
||||||
|
$t = implode("/", $t);
|
||||||
|
return ($t == "" ? $k : $t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return string_plural_select_xx function code
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
|
function tf() {
|
||||||
|
|
||||||
|
$s = "plural_function_code";
|
||||||
|
return (x(App::$strings, $s) ? App::$strings[$s] : "return 0;");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Provide a fallback which will not collide with a function defined in
|
* @brief Provide a fallback which will not collide with a function defined in
|
||||||
* any language file.
|
* any language file.
|
||||||
|
@ -59,7 +59,8 @@ function po2php_run($argc,$argv) {
|
|||||||
$out .= ' return '.$cond.';'."\n";
|
$out .= ' return '.$cond.';'."\n";
|
||||||
$out .= '}}'."\n";
|
$out .= '}}'."\n";
|
||||||
|
|
||||||
$out .= 'App::$rtl = ' . intval($rtl) ;
|
$out .= 'App::$rtl = ' . intval($rtl) . ";\n" ;
|
||||||
|
$out .= 'App::$strings["plural_function_code"] = "return ' . str_replace("$", "", $cond) . ';"';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($k!="" && substr($l,0,7)=="msgstr "){
|
if ($k!="" && substr($l,0,7)=="msgstr "){
|
||||||
|
@ -44,25 +44,27 @@ $(document).ready(function() {
|
|||||||
$(document).on('click', '.conversation-settings-link', getConversationSettings);
|
$(document).on('click', '.conversation-settings-link', getConversationSettings);
|
||||||
$(document).on('click', '#settings_module_ajax_submit', postConversationSettings);
|
$(document).on('click', '#settings_module_ajax_submit', postConversationSettings);
|
||||||
|
|
||||||
jQuery.timeago.settings.strings = {
|
var tf = new Function('n', aStr['plural_func']);
|
||||||
prefixAgo : aStr['t01'],
|
|
||||||
prefixFromNow : aStr['t02'],
|
jQuery.timeago.settings.strings = {
|
||||||
suffixAgo : aStr['t03'],
|
prefixAgo : aStr['t01'],
|
||||||
suffixFromNow : aStr['t04'],
|
prefixFromNow : aStr['t02'],
|
||||||
seconds : aStr['t05'],
|
suffixAgo : aStr['t03'],
|
||||||
minute : aStr['t06'],
|
suffixFromNow : aStr['t04'],
|
||||||
minutes : aStr['t07'],
|
seconds : aStr['t05'],
|
||||||
hour : aStr['t08'],
|
minute : aStr['t06'],
|
||||||
hours : aStr['t09'],
|
minutes : function(value){var str=aStr['t07'].split("/")[tf(value)]; return (str ? str : aStr['t07']);},
|
||||||
day : aStr['t10'],
|
hour : aStr['t08'],
|
||||||
days : aStr['t11'],
|
hours : function(value){var str=aStr['t09'].split("/")[tf(value)]; return (str ? str : aStr['t09']);},
|
||||||
month : aStr['t12'],
|
day : aStr['t10'],
|
||||||
months : aStr['t13'],
|
days : function(value){var str=aStr['t11'].split("/")[tf(value)]; return (str ? str : aStr['t11']);},
|
||||||
year : aStr['t14'],
|
month : aStr['t12'],
|
||||||
years : aStr['t15'],
|
months : function(value){var str=aStr['t13'].split("/")[tf(value)]; return (str ? str : aStr['t13']);},
|
||||||
wordSeparator : aStr['t16'],
|
year : aStr['t14'],
|
||||||
numbers : aStr['t17'],
|
years : function(value){var str=aStr['t15'].split("/")[tf(value)]; return (str ? str : aStr['t15']);},
|
||||||
};
|
wordSeparator : aStr['t16'],
|
||||||
|
numbers : aStr['t17'],
|
||||||
|
};
|
||||||
|
|
||||||
//mod_mail only
|
//mod_mail only
|
||||||
$(".mail-conv-detail .autotime").timeago();
|
$(".mail-conv-detail .autotime").timeago();
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
'name_ok1' : "{{$name_ok1}}",
|
'name_ok1' : "{{$name_ok1}}",
|
||||||
'name_ok2' : "{{$name_ok2}}",
|
'name_ok2' : "{{$name_ok2}}",
|
||||||
|
|
||||||
|
'plural_func' : "{{$plural_func}}",
|
||||||
|
|
||||||
't01' : "{{$t01}}",
|
't01' : "{{$t01}}",
|
||||||
't02' : "{{$t02}}",
|
't02' : "{{$t02}}",
|
||||||
|
Reference in New Issue
Block a user