Closed amenk closed 9 years ago
Already possible, no need to rewrite the input tolerance feature of opening_hours.js :smile:
Note that a warning will be generated in case keywords are used not covered by the spec. Just ignore warnings when in non-OSM use cases.
Good point. But I would like to have a prettified string also with the German codes... But I might be able to omit that.
I am also a native German speaker so German is already quite well supported I think.
Montag-Freitag von 10.00 bis 20.00; Schulferien,Sonn- und Feiertage geschlossen
I know guessed you are :)
But it does not allow to generate a prettified string in German.
What I could do is to ignore all warnings and then after prettifying replace "We" by "Mi" and so on. That might work but not sure if it is that clean?
Simple string replacement is discouraged of course :) For that use case I would recommend to get the tokens array and replace it there. See the demo.html for an example (#47).
how exactly? I can't find any example of such in the demo.html
Search for prettified_value_array
in demo.html.
But then I have to rebuild the string from the array... duplicating half of prettifyValue() ... hm
If you can hack up prettifyValue() to return a nice German representation of the opening hours why not. prettifyValue() can be configured via the conf
parameter. You can add a new conf option like 'locale' and then include it into opening_hours.js.
okay I will try. Could be integrated with the t()
function I guess
Could be integrated with t()
. But I am not sure if this would be a big advantage. It is probably better/simpler to define a hash with all the locales in it something like:
var prettified_value_locales = {
'de': {
'weekday': {
'mo': 'Montag',
}
}
}
It probably does not make sense to integrate it with word_error_correction
, not sure …
But I thought you do not want to increase the size of the opening_hours.js
so much? Or this hash you suggest could be included in the lang file as well ..
The hash prettified_value_locales
could later be moved to it’s own JS module.
OK, right. This (i18next) might be better in that case. suncalc
as an example can also be used by opening_hours.js to have additional features. You can try it with i18next.
or we can use moment's i18n ?
Right, almost forgot moment’s … Yes, that would be the best option to start with. Maybe #65 should be solved first so that this project can use the current version (defined in package.json) …
Here it is
When you are done can you open a PR. I will have a closer look tonight.
There are in #89 lots of messages still to be extracted / translated. Would you have time to do this? Or maybe I can find some colleague. I probably will not have time for it.
Unfortunately this feature is not very high on my priority list and it is a hobby project. If I get funded I would be more than happy to do it :smile:
I think I will do it :-)
is finished. Can you merge?
The library is also useful for non-OSM-used where the opening times are in a local language.
It would be great if it was possible to translate SH / PH / Weekdays / Monthnamess in a local language by specifying a locale.