[REBOL] simple as that ... Re: Re: locale
From: petr::krenzelok::trz::cz at: 26-Aug-2002 10:44
Boleslav Brezovsky wrote:
>>... just kidding ... I think that they think of many things. But -
>>everything is about priorities I think. However - they sell IOS. IF
>>want to sell to non English speaking areas, the right aproach to
>>localisation is needed. And no, sorry, - I am not about to edit each
>>reblet and replace strings in there - forget it - that's not
>>architecture, that's not a concept - I want to be able to switch
>>the languages freely ... ;-)
>Yes, me to :)
>But the question is HOW and if we pick some solution can we hope RT will
>make some use of it or will they come in 3-4 years (maybe less ;) with
>their own solution (of course incompatible) ?
Yes, it is always the risk :-) OTOH, as you can see, RT included some
community code into latest Core updates. So it is upon us, what becomes
widely used. I propose following:
locale: context [
set 'compose-cat-name func [app language /local blk][
blk: parse last split-path app "."
remove back tail blk
append blk join "." [language ".cat"]
join first split-path app blk
set 'get-languages func [app /local available][
available: copy 
foreach file read first split-path app [
if %.cat == suffix? file [append available second head reverse
parse file "."]
either empty? available [none][available]
set 'load-locale func [app /language lang /local available][
language: either language [lang][preferred-language]
either all [
not none? available: get-languages app
find available language
[load compose-cat-name app language][none]
1) preferred-language item being set either in config file, or
2) to have catalogues of app-name.language.cat placed into app directory
3) the only thing needed is to call:
load-locale %/C/rebol/view/app.r ; will load preferred language locale
load-locale/language %/C/rebol/view/app.r "czech" ; will force requested
That's really all, you can assign it to whateve word you want, e.g.
msgs: load-locale ....
- versioning (other functions can be added into object, but imo only
load-locale should be used, so e.g. load-locale/language/version ....
let's not complicate it further .... could be checked easily, if locale
file is an object, it could look like:
app: "app-name" ; not necessary, if we recognize it from file name itself
language: "czeh" ; dtto
menu-item_1: "Otevrit ..." ; open
- someone should clean my script - return issues, naming conventions,
path issues etc.
- I tried to find out script name to allow only load-locale, or
load-locale/language "czech", but if script header doesn't contain
file-name, you will not find it in system structure .... well, otoh it
is maybe good as it is now, as you can call/load locale strings from
outside the app itself - e.g. from translation tool, which could follow
and help to translate apps ...
What do you think?