singleton icon indicating copy to clipboard operation
singleton copied to clipboard

[BUG] [Ruby Client]Plural can't use fallback locale when no translation of the requested strings with placeholder.

Open lyiyu66 opened this issue 3 years ago • 1 comments

Describe the bug Plural can't use fallback locale when no translation of the requested strings with placeholder. getString_f().to_plural_s() SgtnClient::T.s_f().to_plural_s() Notes: New added API supports plurals fallback doesn't has placeholder parameter: getString_p()

To Reproduce Steps to reproduce the behavior: plural rule of locale "en":

<pluralRules locales="ast ca de en et fi fy gl ia io ji lij nl sc scn sv sw ur yi">
            <pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
        </pluralRules>

plural rule of locale "da"

<pluralRules locales="da">
            <pluralRule count="one">n = 1 or t != 0 and i = 0,1 @integer 1 @decimal 0.1~1.6</pluralRule>
            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 2.0~3.4, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
        </pluralRules>

string in source default.yml file:

pluralsstrArg: "%%%%<{ \"cat_count\": { \"one\": \"there is one cat in %2$s and %1$s room\", \"other\": \"there are %%%%{cat_count} cats in %2$s and %1$s room\" } }>"
pluralsstrNamedArg: "%<{ \"cat_count\": { \"one\": \"there is one cat in {A2} and {A1} room\", \"other\": \"there are %{cat_count} cats in {A2} and {A1} room\" } }>"

Method in .rb file:

@DA_Result_one_1dot6_Arg_fallback_EN_other = SgtnClient::Translation.getString_f("JAVA", "pluralsstrArg", ["a1","a2"],"da").to_plural_s("da", { :cat_count => 1.6 })
@DA_Result_one_1dot6_NamedArg_fallback_EN_other = SgtnClient::Translation.getString_f("JAVA", "pluralsstrNamedArg", {"A1": "a1", "A2": "a2"}, "da").to_plural_s("da", { :cat_count => 1.6 })
RequestStore.store[:locale] = 'da'
RequestStore.store[:component] = 'JAVA'
@DA_Result_one_1dot6_Arg_EN_other_T = SgtnClient::T.s_f("pluralsstrArg", ["a1","a2"]).to_plural_s("da", { :cat_count =>1.6 })
Arg = {"A1": "a1", "A2": "a2"}
@DA_Result_one_1dot6_NamedArg_EN_other_T =  SgtnClient::T.s_f("pluralsstrNamedArg", Arg).to_plural_s("da", { :cat_count => 1.6 })

Actual behavior Translation returns to default.yml(EN source), but plurals still use DA's. @DA_Result_one_1dot6_Arg_fallback_EN_other: s_there is one cat in a2 and a1 room @DA_Result_one_1dot6_NamedArg_fallback_EN_other: s_there is one cat in a2 and a1 room @DA_Result_one_1dot6_Arg_EN_other_T: there is one cat in a2 and a1 room @DA_Result_one_1dot6_NamedArg_EN_other_T: there is one cat in a2 and a1 room

Expected behavior Translation returns to default.yml(EN source), plurals should use EN's as well. @DA_Result_one_1dot6_Arg_fallback_EN_other: there are 1.6 cats in a2 and a1 room @DA_Result_one_1dot6_NamedArg_fallback_EN_other: there are 1.6 cats in a2 and a1 room @DA_Result_one_1dot6_Arg_EN_other_T: there are 1.6 cats in a2 and a1 room @DA_Result_one_1dot6_NamedArg_EN_other_T: there are 1.6 cats in a2 and a1 room

lyiyu66 avatar Dec 16 '21 02:12 lyiyu66

These interfaces will be deprecated.

Xiaochao8 avatar May 12 '23 07:05 Xiaochao8