tinytime icon indicating copy to clipboard operation
tinytime copied to clipboard

Localization

Open bjarneo opened this issue 8 years ago • 3 comments

Have you considered localization? My use case would be just to replace https://github.com/aweary/tinytime/blob/master/src/compiler.js#L29 and https://github.com/aweary/tinytime/blob/master/src/compiler.js#L44 with days/months in norwegian.

Basically just injecting two arrays to keep the code tiny.

bjarneo avatar Apr 18 '17 06:04 bjarneo

I haven't considered it, but I would be open to supporting it! We could maintain a set of localizations and create access points for each.

// imports tinytime with norwegian localiziations
import tinytime from 'tinytime/no'

Or if there's a package that already provides these localizations I'm happy to consider using it, or providing an API to integrate with it.

edit providing the API via import paths is actually not a great idea, since it makes dynamic localization trickier. I'm open to providing an API though!

aweary avatar Apr 22 '17 01:04 aweary

Adding it as an option seems to be really easy if I'm not missing anything.

ulrikstrid avatar Apr 23 '17 15:04 ulrikstrid

@aweary do you mean then you would store localisations for each language in the one package? Wouldn't that bloat it a bit?

How about if you make a separate module for each that only has the localisation table in it? So for example you could do:

import tinytime from 'tinytime'
import tinytimeRULocale from 'tinytime-locale-ru'

tinytime.setLocale(tinytimeRULocale)

And then you're not having to maintain a package with localisation keys that make up more and more of the size of the module with each new language?

mtimofiiv avatar Apr 24 '17 12:04 mtimofiiv