Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated

Translations for strings with numeric values for some languages (suffixes)

9 years 9 months ago
Licenses:
JomSocial Expired Socialize Expired

Hello!
I have found some issues with translations (JomSocial 3.2.0.6 - 3.2.1.1).
For some languages with complex word endings for numeric values JText::plural() should be used instead of JText::sprintf().

In ru-RU language, we have to use several keys for the same phrases to take into account different word endings.
For example:
COM_COMMUNITY_LAPSED_DAYS="%1$s days ago"
would translate into:
COM_COMMUNITY_LAPSED_DAYS="%1$s дней назад"
COM_COMMUNITY_LAPSED_DAYS_1="%1$s день назад"
COM_COMMUNITY_LAPSED_DAYS_2="%1$s дня назад"
COM_COMMUNITY_LAPSED_DAYS_MORE="%1$s дней назад"

We have to use several different keys to cover all endings for each number, not only for value=1 and value>1, but for some other values: value=2, value=3 and etc.
You use "if" in php code for echo BASE lang key or BASE_MANY key, but we need the third variant.
I know that JText::plural() with some override can fix it (use suffixes _1, _2, _MORE).
Example for joomla RU language pack: language\ru-RU\ru-RU.localise.php

abstract class Ru_RULocalise
{
//................
	/**
	 * Returns the potential suffixes for a specific number of items
	 *
	 * @param	int $count  The number of items.
	 * @return	array  An array of potential suffixes.
	 * @since	1.6
	 */
	public static function getPluralSuffixes($count)
	{
		if ($count == 0) {
			$return = array('0');
		} else {
			$return = array(($count%10==1 && $count%100!=11 ? '1' : ($count%10>=2 && $count%10<=4 && ($count%100<10 || $count%100>=20) ? '2' : 'MORE')));
		}
		return $return;
	}
//................
}

But we cannot use it in JomSocial component, because JText::sprintf() is hardcoded in your php code (not in templates) instead of JText::plural(). Usage of plural() does not break the ordinary behavior of translator (for example en-GB language), but users can add new language keys with suffixes _1, _2, _MORE to improve their translations.

Some your php files to fix usage of keys:
  • components\com_community\controllers\notification.php
    COM_COMMUNITY_ACTIVITIES_DAYS_AGO
    COM_COMMUNITY_ACTIVITIES_WEEK_AGO_MANY
    COM_COMMUNITY_ACTIVITIES_MONTH_AGO_MANY
  • components\com_community\helpers\time.php
    COM_COMMUNITY_LAPSED_DAYS
    COM_COMMUNITY_LAPSED_WEEK_MANY
    COM_COMMUNITY_LAPSED_MONTH_MANY
    COM_COMMUNITY_LAPSED_YEAR_MANY
  • components\com_community\libraries\activities.php
    COM_COMMUNITY_LAPSED_HOUR
    COM_COMMUNITY_LAPSED_HOURS
    COM_COMMUNITY_LAPSED_HOURS_AGO
    COM_COMMUNITY_LAPSED_MINUTE
    COM_COMMUNITY_LAPSED_MINUTES

9 years 9 months ago
Licenses:

HI, Alexander.

Thank you for your report, I passed it to our developers.


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you
9 years 9 months ago
Licenses:

Hi, Alexander.

Here is PO response:

There is no way we can adopt this for all different languages in the word.

His example for romanian, breaks on my language (serbian)

Example

"pre 1 godinu" - singular
"pre 2 godine" - plural
"pre 3 godine" - plural
"pre 4 godine" - plural
"pre 5 godina" <--- ooops.... plural, but in different case

The thing we have now, works the best for all, so changing it will be dangerous


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you
Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW