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
Add possibility to provide diffrent values for past and future name and pluralName #12
Comments
Hmmm... This is a good question! I'll need to think about it, but I'd love to entertain ideas! |
It's possible that the resource bundle could specify a pluralizer object, which would handle making this type of decusion. How do you think we should do it? |
Currently the decision to use plural name or not is made here: I think the straight forward way would be to add (past|future)[Plural]Name for the time unit and use those. It'd work in this case but would not be very pretty if there would be a need for more similar additions in the future. Another thing that's some what related is the possibility for different time patterns for single and plural cases... At least in Finnish it is more fluent language to leave the number out of the phrase when there's only one eg. "minuutti sitten" vs "1 minuutti sitten". Same as in English "minute ago" vs "1 minute ago". The latter might be more acceptable in English but it looks like poor Finnish. |
Yeah, in English, "1 minute ago" is proper. "Minute ago" doesn't have any meaning. But I can understand that would certainly be different in other languages :) Do you think you could enumerate the different scenarios here so that I can see what types of complexity we are dealing with? E.g: In English I would do this -
Could you do the same thing in finnish, adding any other cases that may be different? Thanks! |
I think it might be possible to add a few extra properties to the resource bundle in order to solve this. plus a few extra conditions in the time units to pick up these new properties. But I'll need to see. |
Ok I wrote the combinations here: https://docs.google.com/spreadsheet/pub?key=0At8V2V1eCy5wdFdCcm8zbWt2U2h5RGl0bHV4MFFlVmc&output=html For Finnish the different name for past and future timeunit would be adequate and maybe different pattern for single and plural. And while we're at it I though about 1 day ago = yesterday and 1 day from now = tomorrow but it would still complicate matters. |
Hey! I'd love to get that working, but we need to strategize an API to make it extendable and not break things :) Will take a look at your list and see what we can think of. Please feel free to suggest interfaces / APIs that would let this work smoothly! |
Well adding the (past|future)[Plural]Name that could be used if present in the bundle and same for pluralPattern. For the special cases maybe Timeformat#decorate could first delegate to some custom decorator passing it the duration and if it knows how to format the duration it could be used and if not do what it does now. Default decorator could eg. use pattern generated from the duration to look up resource bundle like past_1_day=yesterday future_1_day=tomorrow |
Adding another person to this thread for discussion. |
Ukrainian --- look this =)years |
Russian --- look this =) I write upper Changed word. |
what we have?:--- MINUTES
--- HOURS
--- MONTHS
--- YEARS
|
sum in words on Russian ;) on English same function for PrettyTime it`s meybe good |
It sounds like maybe the easiest thing to do is to add an interface to the resource bundles that would allow the resource bundle to handle control over the pluralization. If the bundle implements this resource, then the getPluralizer() can be called to return a Pluralizer object. This object will handle the logic for specific languages, but if not provided, the default behavior will be used. What do you think? |
I think it would work. And after seeing the Ukrainian version I don't think Finnish is so complicated after all ;) |
Haha :) Do you want to take a shot at implementing this, since you know what you need it to do? To be honest, I'm very confused trying to read your languages! :) If you do, try to make sure that you only need to implement the interface in Resource bundles that need this feature. The others should be able to remain unchanged. (I'm thinking about something like, if(bundle implements Pluralizer) { // do the work ... } etc... that might be a good start. |
I'll try to work something out during the weekend... |
sample class for Ukrainian
|
I guess "i" is the amount but what is timeVariant? |
timeVariant it's perfect variant of words we have: English: minute, minutes Samples { "MinuteName", "хвилина" }, or PrettyTime very limit the possibility of forming a normal speech: |
Fantastic! Let me know how I can help! I may try to lay out some kind of initial API if that would be of use :) You guys are the language experts, though! |
Go ahead. I have to say that the Ukrainian/Russian variant is mind boggling :) |
I have friend from Belarusian, and can translate... Minutes: |
Okay guys. Tell me what you think. I had to break backwards compatability to get this to work, but ResourceBundles may now implement TimeFormatProvider, and specify TimeFormat instances for TimeUnits directly: This should give you full control over formatting duration objects. Once we see the patterns required to do this, we could possibly update the API or create some base-classes to make things simpler. For now, however, what I need you guys to do, is to try to implement your Resources_XX files using this new API. It may not be super easy, but you have control. We can make things easier after we see how this needs to work. You can take a look at an example test-case here: https://github.com/ocpsoft/prettytime/tree/master/src/test/java/org/ocpsoft/pretty/time/i18n Please submit pull requests when you have something! |
Consequently, because of the API breakage, the next release will be 2.0. |
Looks good. I'll try to implement the Finnish version during Easter. |
decorateUnrounded not used. test ok. but i not test Russian - Years - 1 год, 2 года, 5 лет. it's dif words. in Ukrainian it's 1 рік, 2 роки, 5 років - we have "р". package org.ocpsoft.pretty.time.i18n;
import java.util.ListResourceBundle; public class Resources_ua extends ListResourceBundle implements TimeFormatProvider @OverRide @OverRide
} } package org.ocpsoft.pretty.time.i18n; import java.util.Date; public class TimeFormatProviderTest /* @test |
Looks like this is working! I have a few questions.
Again, awesome! Looks great so far! |
|
|
.decorateUnrounded() ... - )))
@test |
and only last test not work, and some time test work good, and some time have error, sample: 22 hours 22 minutes ago or moments ago 22 minutes ago.
@test |
I don't believe you want your numbers to start with '-' do you? Also, if your rounded and unRounded methods are the same, why not just call one from the other? |
I am going to close this issue since it seems like this feature is now working. We can continue discussion of your implementation on the forums, or on a pull-request here. |
Is there a way to return 1 day ago as yesterday from the standard resource bundle? I see this considered in this thread |
Hi,
I started making Finnish translation for pretty time but realized that Finnish being awkward language needs different values for name/pluralName depending whether the duration is in the past or future.
eg.
1 minute ago = 1 minuutti sitten
1 minute from now = 1 minuutin päästä
3 minutes ago = 3 minuuttia sitten
3 minutes from now = 3 minuutin päästä
As you can (probably ;) see Finnish word minuutti (= minute) conjugation is different for past and future and it also depends if the duration is singular or not. So using just the past and future suffix leads to grammatically incorrect durations.
I could give this a stab my self but was just wondering what would be the best way to tackle this.
The text was updated successfully, but these errors were encountered: