tinytime
tinytime copied to clipboard
Localization
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.
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!
Adding it as an option seems to be really easy if I'm not missing anything.
@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?