vmware / vmware/singleton

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

Open
#1,405 1 comment 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

area/ruby-client kind/bug priority/low
Dominant language
Java
Stars
72
Forks
69
Avg merge
23h 32m
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.