craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.27k stars 635 forks source link

[5.x]: Translated spelling is not idiomatic in some languages #14800

Closed panlatent closed 6 months ago

panlatent commented 6 months ago

What happened?

Description

Translated spelling is not idiomatic in some languages.

In Chinese (zh), people are used to using Arabic numerals instead of spelling format 2, which represents the quantity, is not translated (extra, it should not be translated as "二", it should be "两"). Craft uses the following code:

Craft::t('app', '{count, spellout} {count, plural, =1{plugin} other{plugins}}', [
    'count' => $count,
]);

Steps to reproduce

Expected behavior

2 => 2

Actual behavior

2 => 二

Craft CMS version

5.0

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

brandonkelly commented 6 months ago

@panlatent The translation for that message can be found in src/translations/zh/app.php. Can you please submit a PR with the corrected translation?

panlatent commented 6 months ago

@brandonkelly I will submit a PR next. The problem is not as simple as I thought. Changing {count, spellout} to {count} will cause the message to be inconsistent with the translation: In the Chinese environment, Intl will complain about plural and throw an exception, causing a fallback to the original translation.

panlatent commented 6 months ago

PR #14810 Finish. Cannot write {var} {var xxx}. yiisoft/yii2#11767