-
Notifications
You must be signed in to change notification settings - Fork 14
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
Localization fails when locale features patterns have no number substitution #20
Comments
@jarrodmoldrich, thanks for the detailed report and sorry for the inconvenience - thats a lot of code-diving you did. I suspect you are right and my very simple substitution code doesn't cater for circumstances where there is no substitution. If thats the case then its quite a simple update. I will work on this over the next 12 hours and revert - hopefully with a new release. |
Awesome, thank you, that's a fast turn-around. Did you have any thoughts about handling negative units? Here's a snippet from the Cldr documentation (emphasis added): https://unicode-org.github.io/cldr/ldml/tr35-general.html#Unit_Elements
My best guess is that you use the |
I have published ex_cldr version 2.19.1 and ex_cldr version 2.20.0-rc.3 that fixes the substitution bug you reported (thanks again for the report and the code for the fix which I used). As the treatment of negative numbers in the case where the template does not have any substitutions. I believe there are two issues at play:
ex> TestBackend.Cldr.Number.Cardinal.plural_rule -1, "he"
:one
iex> TestBackend.Cldr.Number.Cardinal.plural_rule 1, "he"
:one In a situation where a template has substitutions, then number formatting would insert the correct number (ie
If you are able to share your use case then I'd be happy to suggest an appropriate localisation path. |
Plural rules does, as you suggest, use Thanks for the excerpt from my old friend TR35. Let me think on how best to approach what that paragraph suggests. The reference implementation is either the ICU code; either the |
Thanks again @kipcole9 . Really appreciate how quick you've moved on this. As for my use case, I need to display the magnitude of a time change. Which could be forward or backwards an hour, 20 minutes, etc. The
|
@jarrodmoldrich, thanks for sticking with me on this! I think my time is probably better invested in improving the duration code to cater for times and not just dates. Would you mind letting me know where the formatting for I should be able to complete an update to duration calculations (and formatting) by the end of the weekend - is that good enough to meet your timeframe? |
BTW, I don't know if the Hebrew calendar is a part of your requirements but I will eventually get to implementing it. First I need to finish up lunar calculations in my astro. And then the calendar code. Its a very complex calendar so Its not high on my priority list - unless there is unfulfilled demand and I can change priorities. |
That time frame is perfectly fine for me, but don't feel like you need to rush. Bears repeating: I'm very appreciative of your time, and if you wish to delegate work to me, I'm happy to help also. I'm currently only supporting Gregorian atm, so I won't compel you to implement the Hebrew calendar. Though when it is done, I'll probably use it. It's possible there's some formatting options to |
Thanks @jarrodmoldrich, thats clear. Definitely |
Since I don't speak Hebrew, may I ask you if any of the entries here would be grammatically correct for
|
Now I have some good news, and some less good news. Good newsI fixed the bug that prevented creating iex> Cldr.Calendar.Duration.new ~T[00:00:59], ~T[00:01:23]
{:ok,
%Cldr.Calendar.Duration{
day: 0,
hour: 0,
microsecond: 0,
minute: 0,
month: 0,
second: 24,
year: 0
}} The less good news
Continues as a work in progress. |
Sorry for the late reply, but I was AFK. I know this isn't very scientific, but the result of google translate matches with I find it strange, but I'm already able to make time based intervals. But I'm not currently on the bleeding edge RC.
Thanks again for the updates. |
Thanks much. I also fixed the Working on a proper resolution now. Thanks for your patience. |
Hi @kipcole9 , thanks for all those updates. |
Thats very strange - new locale files should automatically download whenever a new release is configured. I've only seen this issue when locales are kept as part of some CI/CD caching. Is that perhaps the case here? |
It is strange. This is my local build, and I haven't explicitly set up any caching. |
Thanks for the feedback, I'll think on this some more. None of the code related to downloading was touched at all although the locale files have definitely changed and for this version they do indeed include a |
I have pushed a commit to resolve this issue according to the except of TR35 you referenced. Would you consider testing your app with this version, directly from GitHub? In your def deps() do
{:ex_cldr_units, github: "elixir-cldr/cldr_units"},
...
end If so, I will await your feedback before I publish a new version. The draft changelog entry is: Bug Fixes
|
@kipcole9 That works great, thank you. It seems that you could have kept the explicit words for A couple of small feature request would be to allow out of order durations, and also to permit a duration from a single scalar duration, like a
Thanks again for turning this around so quick. Impressed and grateful. |
@jarrodmoldrich, the code path still uses Will take a look at what I can do to improve durations as you suggest. I'll move this part of the issue to |
This is what I see with the current iex> Cldr.Unit.to_string Cldr.Unit.new!(1, :hour), locale: "he"
{:ok, "שעה"}
iex> Cldr.Unit.to_string Cldr.Unit.new!(-1, :hour), locale: "he"
{:ok, "-1 שעות"}
iex> Cldr.Unit.to_string Cldr.Unit.new!(1, :hour), locale: "ar"
{:ok, "ساعة"}
iex> Cldr.Unit.to_string Cldr.Unit.new!(-1, :hour), locale: "ar"
{:ok, "-١ ساعة"} |
Ah yes, you have implemented it this way, I misunderstood what you said. I've verified this behaviour is reflecting on my build. |
Ah, good to hear, thanks much. For any future curious people the relevant code is at https://github.com/elixir-cldr/cldr_units/blob/master/lib/cldr/unit/format.ex#L641-L676 I will add some more tests and publish this in the next 12 hours or so. |
Hello @kipcole9 ,
Firstly, thanks for your work on this library, it's much appreciated.
I noticed that localizing an hour unit, or 2 hours, to either "he" or "ar" would result in an error. 3 hours will succeed.
Looking at the cldr data, there appears to be no substitution for the number:
Yet I'm not seeing a function signature that would match such an input:
A naive solution would be to simply add the variants to handle a pattern with no substitution:
... or even to percolate this detection up the call chain, such that
substitute/*
is never even called, but there is an inconsistency. I'm using the function with negative units, which is perfectly fine for most locales, but you'll notice with the example in Hebrew, the negative version is now the same as the positive:I'll probably work around this locally. If you're short on time, I could organise a PR for you, with a little guidance on how you want to deal with these problems.
Thanks for your time, and let me know.
Cheers,
Jarrod
The text was updated successfully, but these errors were encountered: