Skip to content

Support for localization of AM/PM #227

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

Closed
wants to merge 1 commit into from

Conversation

novoj
Copy link

@novoj novoj commented Aug 12, 2011

In czech language we are supporting AM/PM, but we have localized strings "dop." and "odp." for such thing. This is even supported by Java language (and probably others) for formatting and parsing purposes. I tried to add similar support in this patch for the timepicker addon.

…has support for this thing, but it is obviously localized.
@trentrichardson
Copy link
Owner

Ok, I like your changes! Thanks! Only thing I notice right off is around line 680 we will need to force toLowerCase() on all lower case t's. I would say it should be in the localization, but it would be much more convenient and backwards compatible to change the timeFormat. So, I guess like you defaulted will be upper case.

@trentrichardson
Copy link
Owner

Also if you could possibly issue your pull request for the dev branch?

Trent

@novoj
Copy link
Author

novoj commented Aug 12, 2011

Regarding to case: in English there is AM/PM ... in czech we use lower case form dop./odp., so I tried to find all case conversions and removed them. But there might be some corner case where it would cause a problem? But seeing uppercased ODP./DOP. would not look like natural for Czech people.

I try to make pull request to the dev branch as soon as I found out how to do it. I'm a newbie in Git.

@trentrichardson
Copy link
Owner

It is possible in English to see AM/PM, am/pm, A/P, or a/p. I would say AM/PM is the correct/formal way, however its not uncommon to see it other ways, in more informal situations. So possibly we can place the "formal" way in the localization file, and use "TT" to leave it the formal way (upper case, lower case, etc.. which ever is formal). Then we can specify lower case.

.replace(/TT/g, time.ampm)
.replace(/Tt/g, time.ampm)
.replace(/tT/g, time.ampm.toLowerCase() )
.replace(/tt/g, time.ampm.toLowerCase() )
.replace(/T/g, time.ampm.charAt(0))
.replace(/t/g, time.ampm.charAt(0).toLowerCase() )

This should leave it lower case for "TT" and for "tt" for Czech as long as in the localization file you set it as lower case. So TT would always represent exactly how it is in the localization file.

@jun66j5
Copy link
Contributor

jun66j5 commented Aug 12, 2011

I'm also working for the localized AM/PM markers to integrate with Trac - http://trac.edgewall.org/ticket/10245.
I prepared all locale files and the picker can parse localized markers.

jun66j5/jQuery-Timepicker-Addon@trentrichardson:dev...jun66j5:l10n-ampm

@trentrichardson
Copy link
Owner

Hey jun66j5,

What is the status of your changes? This looks to be a thorough update of the AM/PM structure.

@jun66j5
Copy link
Contributor

jun66j5 commented Aug 12, 2011

The work is almost done, excepted default AM/PM markers to show.

When a picker show the selected datetime, it uses the first entry of amNames/pmNames array. In each locale file, the first entry is a localized marker. Most applications cannot parse localized AM/PM markers. (Trac 0.13dev can parse the markers, now.)

Then I think that the first entry should be "AM"/"PM".

diff --git a/localization/jquery-ui-timepicker-cs.js b/localization/jquery-ui-timepicker-cs.js
index 74ef405..e02534b 100644
--- a/localization/jquery-ui-timepicker-cs.js
+++ b/localization/jquery-ui-timepicker-cs.js
@@ -12,8 +12,8 @@
                currentText: 'Nyní',
                closeText: 'Zavřít',
                timeFormat: 'h:m',
-               amNames: ['dop.', 'AM', 'A'],
-               pmNames: ['odp.', 'PM', 'P'],
+               amNames: ['AM', 'A', 'dop.'],
+               pmNames: ['PM', 'P', 'odp.'],
                ampm: false
        };
        $.timepicker.setDefaults($.timepicker.regional['cs']);

Thoughts?

@novoj
Copy link
Author

novoj commented Aug 14, 2011

Should I invest time into the merging my changes into the dev when jun66j5 has more in-depth implementation then? I'am not sure I understand the logic well - but according to this implementation there are multiple abbreviations available for certain languages - for czech dop. either as AM could be used (I do not have use-case for that, but jun66j5 probably has?). Do I get it right? Primary abbreviation should be of course localized one - ie. dop. in this case.

More than that it is necessary to consider character cases - as multiple combinations are allowed in English. This gets really a bit complicated at the end.

@jun66j5
Copy link
Contributor

jun66j5 commented Aug 15, 2011

... but according to this implementation there are multiple abbreviations available for certain languages - for czech dop. either as AM could be used (I do not have use-case for that, but jun66j5 probably has?). Do I get it right?

Right, I think that the picker should parse AM/PM in another locale.
I sometimes use AM instead of 午前 (Japaneses AM marker). Because it's easy to type by keyboard.

Primary abbreviation should be of course localized one - ie. dop. in this case.

Ok. In the my current changes, primary abbr is localized one. I will not modify the code any more.

@trentrichardson
Copy link
Owner

Ok, I've merged the changes by jun66j5. Thanks both for your contributions!

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

Successfully merging this pull request may close these issues.

3 participants