プロジェクト

全般

プロフィール

Vote #81776

完了

Custom I18n Pluralization rules are not applied correctly

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
I18n_37
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
37
version_id:
155
issue_org_id:
36396
author_id:
3866
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
170
ステータス-->[Closed]

説明

Currently "custom pluralization rules":https://guides.rubyonrails.org/i18n.html#locale-specific-rules are not loaded. This is due to the required "@::I18n::Backend::Pluralization@":https://github.com/ruby-i18n/i18n/blob/master/lib/i18n/backend/pluralization.rb module not being loaded in the correct class.


journals

The attached Patch changes the inclusion of @::I18n::Backend::Pluralization@ to the correct class.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Felix, do you think the following code I wrote properly tests the issue?

<pre><code class="diff">
diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb
index 4856c5190..8d076a385 100644
--- a/test/unit/lib/redmine/i18n_test.rb
+++ b/test/unit/lib/redmine/i18n_test.rb
@@ -255,4 +255,13 @@ class Redmine::I18nTest < ActiveSupport::TestCase
set_language_if_valid 'fr'
assert_equal 'French (Français)', l(:general_lang_name)
end
+
+ def test_custom_pluralization_rules
+ I18n.backend.store_translations :en, i18n: {plural: {rule: ->(n) {[0, 1].include?(n) ? :one : :other }}}
+ I18n.backend.store_translations :en, apples: {one: 'one or none', other: 'more than one'}
+ assert_equal 'one or none', ll(:en, :apples, count: 0)
+ assert_equal 'more than one', ll(:en, :apples, count: 2)
+ ensure
+ I18n.reload!
+ end
end
</code></pre>

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Go MAEDA wrote:
> Felix, do you think the following code I wrote properly tests the issue?

Thank you very much for the suggestion. The proposed test should catch a misconfiguration of the `::I18n::Backend::Pluralization` backend in `::Redmine::I18n`.
--------------------------------------------------------------------------------
Setting the target version to 4.1.6.
--------------------------------------------------------------------------------
Committed the fix. Thank you.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,21856,I18n backend does not support original i18n Pluralization
relates,Closed,36461,I18nTest#test_custom_pluralization_rules randomly fails

Admin Redmine さんが3年以上前に更新

  • カテゴリI18n_37 にセット
  • 対象バージョン5.0.0_155 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0