Skip to content
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

Issue with 11..19 and n1 numbers and polish locale #13

Closed
jcubic opened this issue Sep 9, 2016 · 5 comments
Closed

Issue with 11..19 and n1 numbers and polish locale #13

jcubic opened this issue Sep 9, 2016 · 5 comments

Comments

@jcubic
Copy link
Contributor

jcubic commented Sep 9, 2016

I've created Polish locale (will create PR) but have problems. In polish
"1 month" ago is "1 miesiąc temu"
"%s months ago" is "%s miesięce temu"
but for numbers 11..19, 21 31, ..., 91 is "%s miesięcy temu"

and there is no way to have this locale without modification of the library. Maybe locale be a function that accept number and unit like:

function locale(number, unit) {
   var str = number.toString();
   if (unit == 'hours') {
       if (number == 1) {
          return ['1 godzinę temu', 'za 1 godzinę'];
       } else if (str.length == 2 && str[0] == "1" || number % 10 == 1) {
          return ['%s godzin temu', 'za %s godzin'];
      } else {
        return ['%s godziny temu', 'za %s godziny'];
      }
  }
}

and the code can detect if locale is function or array.

@hustcc
Copy link
Owner

hustcc commented Sep 9, 2016

@@, ^==^
so function locale should be allowed, or the only way of locale is function?

@jcubic
Copy link
Contributor Author

jcubic commented Sep 9, 2016

I think it should be allowed, so the old locale will work without the need to covert them to functions.

@hustcc
Copy link
Owner

hustcc commented Sep 9, 2016

OK, It can only be this way. Polish is a very specia language ^_^~

You can just do it, but keep the library little, and the tests/locales_test.js must be updated also.

@hustcc
Copy link
Owner

hustcc commented Sep 9, 2016

In fact, the locales were added in 2 days (today and yesterday), so I think the locales rule can be updated. The rules now is not very prefact, it can be:

  1. all locales can be independent module;
  2. timeago.register('locale_name', locale_func), the locale_func can be require from 1 ;
  3. the build in locales(en, zh_CN) can modified to function.

If change the locales rule to above, the library maybe more tiny and prefact.

hustcc pushed a commit that referenced this issue Sep 9, 2016
@hustcc
Copy link
Owner

hustcc commented Sep 9, 2016

just have a look 5c834b3. @NicoJuicy @paulcmal @CreativeSparkStudios @jcubic

update the locales, use locale function. and all locale.js should be a javascript module.

// register
timeago.register('da', require('timeago.js/locales/da'));

// then use it
timeago.format(date, 'da');

the locales rule more prefact, and the library from 2.5kb to 2.1 kb. ^_^~

hustcc pushed a commit that referenced this issue Sep 9, 2016
How to set a new locales.
hustcc pushed a commit that referenced this issue Sep 9, 2016
how to register a locale ?
/Users/xiaomei/java_tool/apache-maven-3.3.3
@jcubic jcubic mentioned this issue Sep 9, 2016
@jcubic jcubic closed this as completed Sep 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants