Multilingual dialogues

Trevor DeVore lists at mangomultimedia.com
Thu Oct 20 11:03:04 EDT 2005


On Oct 19, 2005, at 5:55 AM, David Bovill wrote:
>
> Structurally I am thinking of associating each dialogue with a  
> unique object (usually the object that calls the dialog = the  
> target) and being able to call / reuse the same dialogue from  
> another object using a custom property .- something like:
>
>     - put the answer_Dialogue["German"] of btn "Question" into  
> someAnswer
>
> Anyone have any advice or code to simplify this?

Here are my thoughts on this.

One way to handle this is to have a stack named "language" in memory  
and the name of the language on disk.  It contains all translated  
strings for a given langauge in a custom property set.  The set might  
look like this:

uLanguage["tt.MyTooltip"]
uLanguage["dlg.AskForFile"]
etc.

After finishing your primary language file, you can write a routine  
which will take all of the custom properties of this stack and export  
a key/value pair to a file that your translators can translate.  Then  
you can have an importer which reads the file and creates a new  
language stack for German, French, etc.

Now write a function for retrieving the strings easily.  If you  
needed to do any modifications (switch encodings, etc.) to the string  
before returning it you could do it here.  The function will access  
the string of whatever language stack file is currently loaded into  
memory.

function getString pKey
     return the uLanguage[pKey] of stack "language"
end getString

Now to call a dialog just do this:

answer getString("dlg.AskForFile")


You can simplify setting tooltips and field text values by using code  
like this when a stack opens for the first time.  It just looks for  
custom properties of controls that specify what key in the language  
stack to use for that control.

repeat with i = 1 to the number of cards of this stack
     repeat with j = 1 to the number of controls of this stack
         if the uLocale["tooltip"] of control j of card i of this  
stack is not empty then
             set the tooltip of control j of card i of this stack to \
                 getString(the uLocale["tooltip"] of control j of  
card i of this stack)
         end if

         if the uLocale["text"] of control j of card i of this stack  
is not empty then
             set the text of control j of card i of this stack to \
                 getString(the uLocale["tooltip"] of control j of  
card i of this stack)
         end if
     end repeat
end repeat

Anyway, just some thoughts.

David - I've tried answering the email you sent me but it keeps  
getting bounced.  I've tried a couple of accounts but I think I am  
not on your spam list.


-- 
Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com





More information about the use-livecode mailing list