mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-06 16:53:34 +02:00
Proposition of translations about:
A recent picture is a last picture but a last picture is not a recent picture. A recent category is a last category but a last category is not a recent category. So it's a proposition about last is not like recent. Improvement of string including decimal number in order to concord singular and plural. Now, function l10n_dec must be used. git-svn-id: http://piwigo.org/svn/trunk@1637 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -934,6 +934,21 @@ function l10n($key)
|
||||
return isset($lang[$key]) ? $lang[$key] : $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the prinft value for strings including %d
|
||||
* return is concorded with decimal value (singular, plural)
|
||||
*
|
||||
* @param singular string key
|
||||
* @param plural string key
|
||||
* @param decimal value
|
||||
* @return string
|
||||
*/
|
||||
function l10n_dec($singular_fmt_key, $plural_fmt_key, $decimal)
|
||||
{
|
||||
return sprintf(l10n(($decimal > 1 ? $plural_fmt_key :
|
||||
$singular_fmt_key)), $decimal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate string in string ascii7bits
|
||||
* It's possible to do that with iconv_substr
|
||||
|
||||
@@ -373,7 +373,7 @@ function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_
|
||||
|
||||
if ($count > 0)
|
||||
{
|
||||
$display_text.= sprintf(l10n(($count > 1 ? 'images_available' : 'image_available')), $count);
|
||||
$display_text.= l10n_dec('image_available', 'images_available', $count);
|
||||
|
||||
if ($cat_nb_images > 0)
|
||||
{
|
||||
@@ -384,7 +384,7 @@ function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_text.= ' '.sprintf(l10n(($cat_count_categories > 1 ? 'images_available_cats' : 'images_available_cat')), $cat_count_categories);
|
||||
$display_text.= ' '.l10n_dec('images_available_cat', 'images_available_cats', $cat_count_categories);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -347,11 +347,11 @@ function news_exists($start, $end)
|
||||
/**
|
||||
* Formats a news line and adds it to the array (e.g. '5 new elements')
|
||||
*/
|
||||
function add_news_line(&$news, $count, $format, $url='', $add_url=false)
|
||||
function add_news_line(&$news, $count, $singular_fmt_key, $plural_fmt_key, $url='', $add_url=false)
|
||||
{
|
||||
if ($count > 0)
|
||||
{
|
||||
$line = sprintf($format, $count);
|
||||
$line = l10n_dec($singular_fmt_key, $plural_fmt_key, $count);
|
||||
if ($add_url and !empty($url) )
|
||||
{
|
||||
$line = '<a href="'.$url.'">'.$line.'</a>';
|
||||
@@ -381,39 +381,32 @@ function news($start, $end, $exclude_img_cats=false, $add_url=false)
|
||||
|
||||
if (!$exclude_img_cats)
|
||||
{
|
||||
$nb_new_elements = nb_new_elements($start, $end);
|
||||
if ($nb_new_elements > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new elements'), $nb_new_elements));
|
||||
}
|
||||
add_news_line( $news,
|
||||
nb_new_elements($start, $end), '%d new element', '%d new elements');
|
||||
}
|
||||
|
||||
if (!$exclude_img_cats)
|
||||
{
|
||||
$nb_updated_categories = nb_updated_categories($start, $end);
|
||||
if ($nb_updated_categories > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d categories updated'),
|
||||
$nb_updated_categories));
|
||||
}
|
||||
{
|
||||
add_news_line( $news,
|
||||
nb_updated_categories($start, $end), '%d category updated', '%d categories updated');
|
||||
}
|
||||
|
||||
add_news_line( $news,
|
||||
nb_new_comments($start, $end), l10n('%d new comments'),
|
||||
nb_new_comments($start, $end), '%d new comment', '%d new comments',
|
||||
get_root_url().'comments.php', $add_url );
|
||||
|
||||
if (is_admin())
|
||||
{
|
||||
add_news_line( $news,
|
||||
nb_unvalidated_comments($end), l10n('%d comments to validate'),
|
||||
nb_unvalidated_comments($end), '%d comment to validate', '%d comments to validate',
|
||||
get_root_url().'admin.php?page=comments', $add_url );
|
||||
|
||||
add_news_line( $news,
|
||||
nb_new_users($start, $end), l10n('%d new users'),
|
||||
nb_new_users($start, $end), '%d new user', '%d new users',
|
||||
get_root_url().'admin.php?page=user_list', $add_url );
|
||||
|
||||
add_news_line( $news,
|
||||
nb_waiting_elements(), l10n('%d waiting elements'),
|
||||
nb_waiting_elements(), '%d waiting element', '%d waiting elements',
|
||||
get_root_url().'admin.php?page=waiting', $add_url );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user