Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: locale Re: Re: %Maoww_english.r

From: carl:cybercraft at: 25-Aug-2002 1:33

On 24-Aug-02, Boleslav Brezovsk=FD wrote:
> I'm writing Castro (Red Commander) as localized. I've patched > VID-styles so they check for language in feel/redraw function and > you can change language dynamically while running that program. But > I'm still not sure how to organize different language versions. Now > I use this approach - before every string written in english is > function 'translate that checks for language and "translates" > string. So, with new versions, if it does not find translation for > some string original string is used. But on the other hand I must > use function 'translate before every string. > Any ideas?
Would this be anything like you'd want?... lang-1: [word-1 "abc"] lang-2: [word-1 "xyz"] lang: copy/deep lang-1 change-lang: function [new-lang][x][ foreach [word value] new-lang [ if x: find/tail lang word [insert clear x/1 copy value] ] ] lo: layout [ text lang/word-1 button "Lang-1" [change-lang lang-1 show lo] button "Lang-2" [change-lang lang-2 show lo] ] view lo A show of a layout will update the whole layout, while the "insert clear x/1" (instead of "x/1:") in change-lang ensures the text in the layout is referencing the new text - since the new text is still the same reference. --- Incidentally, I'd wondered how to localise functions - and localising the comments at least would be quite easy... lw: [ desc "Sums two numbers." arg-1 "First value" arg-2 "Second value" ] sum: func reduce [ lw/desc 'a [number!] lw/arg-1 'b [number!] lw/arg-2 ][ a + b ]
>> sum 2 2
== 4
>> ? sum
USAGE: SUM a b DESCRIPTION: Sums two numbers. SUM is a function value. ARGUMENTS: a -- First value (Type: number) b -- Second value (Type: number) How useful that would be without the rest of the function being localised is debatable though. -- Carl Read