twitter / twitter-cldr-rb

Ruby implementation of the ICU (International Components for Unicode) that uses the Common Locale Data Repository to format dates, plurals, and more.
Apache License 2.0
672 stars 93 forks source link

Country names output short alternatives when not requested #221

Closed shaicoleman closed 5 years ago

shaicoleman commented 5 years ago

For example, in the file common/main/pt.xml the CLDR contains the following data

        <territories>
            <territory type="US">Estados Unidos</territory>
            <territory type="US" alt="short">EUA</territory>
        </territories>

However, the country name outputs the short alternative, when a short alternative wasn't requested. The expected behaviour would be to output the default variant.

TwitterCldr::Shared::Territories.from_territory_code_for_locale(:us, :pt)
=> "EUA"
TwitterCldr::Shared::Territories.from_territory_code_for_locale(:us, :id)
"A.S."

The acronyms might not be well known to all users around the world, and many times would not be easily searchable (e.g. try searching for EUA in google.pt)

Perhaps in the future an option could be added to those who wish to get the short variant, but it shouldn't be the default.

camertron commented 5 years ago

Hey @shaicoleman, thanks for reporting. I'm in the process of working on updating the library to CLDR v35.1 and hoping to have it ready by the end of the week. Do you have a sense for whether or not this particular problem is caused by relying on an outdated CLDR release, or is it a problem with the implementation? Having not looked into this at all I don't know.

shaicoleman commented 5 years ago

It seems to be caused by implementation. I didn't look into the code, but my guess is that there is a hash of codes => names, and the hash entries get overwritten when they see the second entry with a short name

camertron commented 5 years ago

@shaicoleman hmm ok. In that case, how would you feel about submitting a PR?

shaicoleman commented 5 years ago

@camertron, after running rake update:locales_resources it updates the XML files with the full country names

camertron commented 5 years ago

@shaicoleman oh nice, so updating to 35.1 or 36 should fix things for you?

shaicoleman commented 5 years ago

Yes, it should

camertron commented 5 years ago

Please see my comment on #222.

shaicoleman commented 5 years ago

cldr35 branch looks good

camertron commented 5 years ago

Just published v5.0.0 of the gem :)