-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locale "sr-Latn" is not working: supporting script subtags #10
Comments
Hello. Thank you for your report. Can you please provide more realistic example? We both know that I'd glad to try to understand, cover with tests and fix it. |
To be honest, And there were no reports for 2.5 years, so, I guess, it's not a big deal. 😅 Also we have tests for "different locales (regions) under the same parent locale" here: https://github.com/r18n/r18n-core/blob/28c1d46/spec/r18n_spec.rb#L195-L206 So… I can understand a code error, but I want to know what better to test, how it affects projects. |
Indeed, now I see most locale classes with a secondary element are named in a format like What it harms are those such as require 'r18n-core'
R18n.set "en-us"
puts R18n.t.yes # => "Yes"
R18n.set "zh-tw"
puts R18n.t.yes # => "是"
R18n.set "sr-latn"
puts R18n.t.yes # => "Yes" <- falls back to English even .yml exists!
open('sr.yml', 'w:utf-8') do |sr|
sr.puts "'yes': да"
end
open('sr-latn.yml', 'w:utf-8') do |srl|
srl.puts "'yes': da"
end
R18n.default_places = '.'
R18n.set "sr-latn"
puts R18n.t.yes # => "да" So maybe no one from Serbia has used this gem 🙄. And when we're at it, what would you say to supporting script subtags? Outside |
It seems a lot more complicated than I thought. For example: https://en.wikipedia.org/wiki/IETF_language_tag#Extension_U_(Unicode_Locale) So, "locale" can have a lot of "tags". And the second one can be either region or script or anything else. Meh. Two ideas:
|
I think the latter would be a well-balanced option. You should also support 3-letter language codes as in the standard. (Note that script comes before region, so it must be
The whole system of IETF language tag is indeed complex, but half of them (including what you cited) are for domain-specific or backward compatibility things not immediately needed for user-facing locales. Almost all cases can be covered with three elements: |
In
r18n/locale.rb
:r18n-core/lib/r18n-core/locale.rb
Line 121 in f7bc300
This line seems to have an easy logic error, because:
Perhaps the problem has been elusive because it was introduced with the parent locale function (2c88300), and no one tried to use different locales under the same parent locale at once.
The text was updated successfully, but these errors were encountered: