L10N module (for discussion only)#5059
Conversation
| standard-modules: [ | ||
| ;-- Name ------ Entry file -------------- OS availability ----- | ||
| View %modules/view/view.red [Windows macOS Linux] | ||
| ;-- Name ---------- Entry file -------------------- OS availability ----- |
There was a problem hiding this comment.
I decided to list all locales instead of loading them by mask, because:
- security (e.g. someone leaves malicious script in
%temp%/modules/l10n/and it gets included into the runtime) - I always have a lot of temporary scripts in the Red tree, don't want them to affect the build
|
|
||
| locale: context [ | ||
| language: | ||
| language*: ;-- in locale language |
There was a problem hiding this comment.
I removed the * names because IMO they are very cryptic. I couldn't figure out what they are for until I found comments in the code.
| numbers: none ;-- digits, symbols, numeric masks | ||
| calendar: none ;-- standalone, format, date masks | ||
| months: none ;-- shortcut for standalone month names (R2-compatibility) | ||
| days: none ;-- shortcut for standalone day names (R2-compatibility) |
There was a problem hiding this comment.
months and days seems to come from R2, but I should question their usefulness.
We have data for both standalone (used in calendar) and formatted (used in dates) month and day names as system/locale/calendar/format/months/full and ../standalone/months/full (and days), but these two are shortcuts for the standalone version only.
Moreover, in our data we have days as a map: #(sun "Sunday" .. mon "Monday") etc, because first day of the week is different in different locales (in fact, about 50/50 split between Monday and Sunday), and days order as a block of 1-7 indexes where 1=Monday (as it came from R2) may be confusing.
There was a problem hiding this comment.
I believe, that this area is not easy to get right in al its complexity. But having months / days available under calendar/format/months/full makes me ask - what is format here? What is full here? Sounds quite cryptic, but I can understand that most probably inner structure is not something for an end user to care about, if there are accessor functions to easily get such elements.
There was a problem hiding this comment.
It will be too big to include here. Just see for example cs.red file.
There was a problem hiding this comment.
Data is meant not only for format functions (in fact, only format branch is used by them), but also if you want to localize your UI or smth. Or you can write your own locale or modify already existing (e.g. by adding strings: map for all UI elements text). So it's for more involved users.
| ;@@ we should expect rule for n=10 to succeed but it won't | ||
| ;@@ TODO: reconsider `n` value | ||
|
|
||
| system/locale/cardinal: to map! to block! object [ |
There was a problem hiding this comment.
Lack of object to map conversion or ability to put functions into maps directly makes this a little awkward.
You can build the consoles to check it out (I added the module temporarily into them for testing):
Biggest questions are (as always): data structure and naming.
See the Files changed tab for more.
Biggest issue is how to load best locale for the user?
I added loading code into the console init script for now, but for compiled scripts one will have to manually insert
do bind [load-locale get-best-locale-id] system/locale/toolsbefore the code, which is something I'd like to avoid.Problem is, currently compiled code has the following structure:
boot.red-> modules -> user's script. There's nothing at all after modules (including data from chosen locales) have been loaded and before user script starts.Another problem is that modules cannot declare their own
needs(they can, but it will just be ignored), so writing a module that depends onL10Nmodule being loaded before it is impossible until we getneedsthat can include otherneeds. Consequentlyneedsis also currently ordered, although I managed to write it so that one specify modules in any order.Also,
Formatmodule I think should includeLocales/redand it's dependencies because/redcontains the data most useful forFormat. Another place whereneedsneeds dependency resolution.Ultimately it should be possible to write a module that not only includes
L10Nbut also lets it load the best available locale before evaluating itself.Planned usage
Needs: "L10Nto include every available locale and needed functionsNeeds: [L10N-Core Locales]same as aboveNeeds: [L10N-Core Locales/red Locales/en Locales/root]minimal set needed to able to format dates and times for networking (redis based onenwhich is based onroot- this is where I wish I could writeNeeds: Locales/enin the header ofredandLocales/rootin the header ofen).Needs: [L10N-Core Locales/ru Locales/ru_RU Locales/cs Locales/cs_CZ Locales/root]- example to support only 2 locales Russia and Czech Rep (again, list is long because there is no implicit inheritance, and if I used#includeI would end up with multiple inclusions of the same data both between different#includes and between#includes andneedsitself)Licensing
If I understood Unicode license at all, derivative data still has to be licensed under their license. This however gets rather blurry to me, for example for
plural.redfile which contains my code based on their data. Suggestions?