Problem with Czech language

Splash Forums PrettyTime Users Problem with Czech language

This topic contains 5 replies, has 3 voices, and was last updated by  Lincoln Baxter III 3 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #19135

    minh
    Member

    Hi,

    i’m from Czech republic and czech language is pretty complicated (like many other slavic languages). I would realy appreciate if I can set up unit singular and plural form separately for future and past.

    Example:

    English: 1 month ago

    Czech: Před 1 měsícem

    English: 1 month from now

    Czech: za 1 měsíc

    English: 2 months ago

    Czech: Před 2 měsíci

    English: 2 months from now

    Czech: za 2 měsíce

    Past:

    Singular – month – měsícem

    Plural – months – měsíci

    Future:

    Singular – month – měsíc

    Plural – months – měsíce

    Is there any other way to achive this behavior?

    #23262

    Hi There,

    Yes, this is possible, but it hasn’t been added to the translation guide yet because we haven’t gotten much feedback on the API – you could help us out by being among the first to try it!

    Basically, the concept is that you need to implement the TimeFormatProvider interface in your ResourceBundle.

    /**
    * Produces time formats. Currently only to be used on Resource bundle implementations when used in
    * {@link ResourcesTimeFormat} instances..
    *
    * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
    */
    public interface TimeFormatProvider
    {
    /**
    * Return the appropriate {@link TimeFormat} for the given {@link TimeUnit}
    */
    public TimeFormat getFormatFor(TimeUnit t);
    }

    This allows you to handle formatting uniquely for each unit, and thusly, also allows you to do do things like supply a different name for past, future, plural, or singular. The downside here is that the API is pretty low-level, so you need to do a bit of work.

    It may be possible just to add some additional entries in the resource bundle “PastPluralName” “FuturePluralName” PastSingularName” “FutureSingularName”. But this is currently not implemented. If these special fields were not provided, the format would need to fall back to the current schema. Would this solve your problem?

    Thank you for trying, and thank you in advance for your feedback!

    ~Lincoln

    #23263

    Update, I’ve implemented this feature and documented it in the translation guide. You can now specify Future and Past Plural and Singular names for each time unit.

    Translate for your Language

    Enjoy!

    #23264

    Also, please let me know if this solves your problem :)

    #25343

    Martin Kouba
    Participant

    FYI singular and plural form is not enough for Czech lang. I’ve just sent a pull request with resource bundle and test:
    https://github.com/ocpsoft/prettytime/pull/62

    It would be nice to have the API poweful enough to handle similar requirements – right now every bundle has its own solution/workaround. But I know it would be pretty difficult 🙂

    Martin

    #25344

    Yeah, I know :/ It’s so complicated that it is indeed very difficult to provide a standard API. I’m sure that there are linguists out in the world who understand the needs of most languages, but unfortunately I’m not one of them 🙂 So I’m open to ideas.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Comments are closed.