Localization : how to
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 29
- Joined: Wed Feb 14, 2007 3:26 pm
- Location: FRANCE, Villeneuve d'Ascq
Localization : how to
Hi,
I'm french and until now I always developped my RR tools with a french GUI, without building standalones (useless).
My skills :
- scripting : near expert ; was using Hypercard, then Supercard and now RR for years !
- SQL, XML (for my present projects) : say ... intermediate !
Now, I'd like to build standalones with french localization !
I know how to buld standalones that work but still have problems with menubar localization !
My questions :
1
Is there a prefered place here on these forums to discuss that ? Seems not !
2
Are there some tutorials to help on localization ? Not found !
3
Looking for tools allowing near automatic or assisted edition of translations for various items in an application (btns, wd titles, menu items ...) with help of XML files, for example. Could you help ?
4
Deeper, Mac OSX : when building "Help" and "File" menus and menu items, and giving them french names, some items are moved or discarded, or not moved if name is "A propos de..." (french) insteed of "About..." for example ! All this make me mad ! Not found any help on this in RR documentation !
Could you help me ?
Thx
Eric
I'm french and until now I always developped my RR tools with a french GUI, without building standalones (useless).
My skills :
- scripting : near expert ; was using Hypercard, then Supercard and now RR for years !
- SQL, XML (for my present projects) : say ... intermediate !
Now, I'd like to build standalones with french localization !
I know how to buld standalones that work but still have problems with menubar localization !
My questions :
1
Is there a prefered place here on these forums to discuss that ? Seems not !
2
Are there some tutorials to help on localization ? Not found !
3
Looking for tools allowing near automatic or assisted edition of translations for various items in an application (btns, wd titles, menu items ...) with help of XML files, for example. Could you help ?
4
Deeper, Mac OSX : when building "Help" and "File" menus and menu items, and giving them french names, some items are moved or discarded, or not moved if name is "A propos de..." (french) insteed of "About..." for example ! All this make me mad ! Not found any help on this in RR documentation !
Could you help me ?
Thx
Eric
The Erikoded Frenchy
La logique est le dernier refuge des gens sans imagination
Oscar Wilde :: Logic is the last refuge of the unimaginative
La logique est le dernier refuge des gens sans imagination
Oscar Wilde :: Logic is the last refuge of the unimaginative
-
- Livecode Opensource Backer
Re: Localization : how to
Hello Eric,
French speaker here as well .
The trick is to have somewhere high enough in the message hierarchy, a function localized being defined as:
Rather than have all localization editing lines at top (stack level), I often prefer to have them at card or group level. This way, if I make any change, I can easily keep track of the UI elements that have been added or deleted.
It is sometimes handy to get this managed via a setProp construct.
Marielle
French speaker here as well .
Talking revolution could do, as it is for intermediate skills. This thread would do.Eric_Taquet wrote:1 Is there a prefered place here on these forums to discuss that ? Seems not !
Not that I know about.Eric_Taquet wrote:2 Are there some tutorials to help on localization ? Not found !
Can you be more precise? I assume you know of the existence of a XML library. Is it that you would be after a script that allows for the serialization and deserialization of an interface and its elements (by that I mean that labels, titles, etc. are read or written to an external file, XML in this context)Eric_Taquet wrote:3 Looking for tools allowing near automatic or assisted edition of translations for various items in an application (btns, wd titles, menu items ...) with help of XML files, for example. Could you help ?
The trick is to have somewhere high enough in the message hierarchy, a function localized being defined as:
Code: Select all
function localized pEntry
set the localized_language of this stack into tLanguage
switch tLanguage
case "French"
put "french.xml" into tFile
... whatever else ...
break
case "English"
put "english.xml" into tFile
... whatever else ...
break
... other languages as required...
end switch
put getLocalizedValue(tFile, pEntry) into tValue
return tValue
end localized
It is sometimes handy to get this managed via a setProp construct.
Code: Select all
setProp cardTitle
set the name of this card to localized("cardTitle")
end cardTitle
Not sure what you mean exactly, I tend to add my own help button rather than alter the menus. Can you provide us with a concrete example?Eric_Taquet wrote:4 Deeper, Mac OSX : when building "Help" and "File" menus and menu items, and giving them french names, some items are moved or discarded, or not moved if name is "A propos de..." (french) instead of "About..." for example ! All this make me mad ! Not found any help on this in RR documentation !
Marielle
Here is how I handle localization... no need for an XML file, just place the alternate names in a custom property of the object that can change names. Makes for a nice UI experience in entering the different names on every object creation. Then simply call this script that cycles thru every object when the user asks for a language change:
Code: Select all
on changeLanguage theLanguage
put "loc" & theLanguage into theCustomProp
repeat with x = 1 to the number of cards of this stack
put the objects of card x into cardObjects
repeat with y = 1 to the number of lines of cardObjects
put line y of cardObjects into currentObject
do merge("put the [[theCustomProp]] of currentObject into myText")
if myText is empty then next repeat
put replaceText(myText,return,quote & " & return & " & quote) into myText
put word 1 of the name of currentObject into objectType
-----------
switch objectType
case "field"
do format("put (\"%s\") into %s",myText,currentObject)
break
case "button"
do format("set the label of %s to (\"%s\")",currentObject,myText)
break
default
answer error "Unknown object type while appliying a localized translation." & \
return & return & "Object type:" && objectType &\
return & "Obeject Name:" && currentObject
end switch
end repeat
end repeat
end changeLanguage
getProp objects
repeat with x = 1 to number of controls of the target
put the long name of control x of the target & return after myList
end repeat
sort myList
return myList
end objects
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
A propos localization, has anyone developed an automatic way of replacing the right strings in the script with another language?
The problem being this:
Answer "Press Button 1" --should be localized
Put "Something is nice" into x; put x into field 1 --also localized
send "mouseUp" to button "Press me" --do NOT localize
I can't think of any automatic way of doing this, unless I change my scripting style to always use customProps instead of quoted text. So in my oppinion one needs to do unecessary much work in rev to localize anything at all.
As for the question:
Rev moves an "about..." menu entry from the "help" menu to the automatic generated "application" menu in mac os x (same with the "quit" entry from the file menu).
If that menu is for example "Ãœber..." (respectively "Beenden"), or any other string, rev doesn't recognize the menu and doesn't move them.
I don't know any workaround for this.
Also I haven't used any menus since years, due to this and other shortcomings in the way rev handles menus.
The problem being this:
Answer "Press Button 1" --should be localized
Put "Something is nice" into x; put x into field 1 --also localized
send "mouseUp" to button "Press me" --do NOT localize
I can't think of any automatic way of doing this, unless I change my scripting style to always use customProps instead of quoted text. So in my oppinion one needs to do unecessary much work in rev to localize anything at all.
As for the question:
Rev moves an "about..." menu entry from the "help" menu to the automatic generated "application" menu in mac os x (same with the "quit" entry from the file menu).
If that menu is for example "Ãœber..." (respectively "Beenden"), or any other string, rev doesn't recognize the menu and doesn't move them.
I don't know any workaround for this.
Also I haven't used any menus since years, due to this and other shortcomings in the way rev handles menus.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
You go with the english version and put an empty german.lproj folder into the app bundle. The translation is managed by the OS then.BvG wrote: unless I change my scripting style to always use customProps instead of quoted text.
Yes.
As for the question:
Rev moves an "about..." menu entry from the "help" menu to the automatic generated "application" menu in mac os x (same with the "quit" entry from the file menu).
If that menu is for example "Ãœber..." (respectively "Beenden"), or any other string, rev doesn't recognize the menu and doesn't move them.
I don't know any workaround for this.
Also I haven't used any menus since years, due to this and other shortcomings in the way rev handles menus.
Hope that helps,
Malte
-
- Posts: 29
- Joined: Wed Feb 14, 2007 3:26 pm
- Location: FRANCE, Villeneuve d'Ascq
Thx everybody !
(excuse-me, my english is not so good !)
You all give me some trick !
---------------------------------------
@marielle Bonjour Marielle, Merci !
you wrote (#3) :
I assume you know of the existence of a XML library. Is it that you would be after a script that allows for the serialization and deserialization of an interface and its elements
Yes ! I like this approch with setprop and xml.
One benefit of gathering all translation items into an external file (XML for ex.) is that you have all information in one place and simply available to the translator. On the contrary, using customprops can make you forget some objets, and require people that do translation (not necessary the developper) to go inside your app.
(#4) BvG (above) have describe the problem more clearly than I did
---------------------------------------
@xApple
your changeLanguage handler is interesting, but with a small "tuning". I mean :
I think all btns do not need to have their label translated, all fld contents also do not need tanslation. I've build some apps for teaching Internet technologies to french children and of course all the material MUST NOT be automatically translated !
So, a systematic automatic localization is not, in my mind, always needed !
Objets would have to be localized only if they own some special custom prop. For example, a btn label is to be localized if the btn have a "label.fr" property (that contains the translated label, of course)
---------------------------------------
@BvG
For translation of quoted strings I used to replace these strings with a call to a translation function :
Answer LZ("Stack 1.Cd 1.Answer 2") -- "Press Button 1"
Put LZ("Stack 1.Cd 2.Fld 1") into x; put x into field 1 -- "Something is nice"
send "mouseUp" to button "Press me" -- in this case, "Press me" could be the name of the btn, not its label, so no localization needed here (except for the label)
I always put the original english string as a comment ! For readability.
My localization function LZ retrieves the string either in some custom props of a localized pref stack (that can be modified even after the app has become a standalone) either in an XML file.
To identify the string to retrieve, I used to name them with some kind of dot path (see example). This allows to use translations adapted to contexts. For example, the english word "to" is translated in "vers" or "Ã " french words according the the context !
A bad practice (I've seen it in some PHP apps like source forge webcalendar) would be to use the form ...LZ("Press Button 1")... for the reason mentioned just above ; and because the translator cannot know where the string is used and how it can be well translated !
Last, but not least : I can retrive, in all my scripts, the places where translation/localization has been put : I do a find with "LZ("
The most important response I was waiting for is about "About..." or "A propos..."
I'm unhappy it seems there is none !
A solution (suggestion to RR team !) would be to have a name AND a label for menus and menutitems ! Like it is for btns. So, you could easily refer to those objects withing your scripts, whatever their names are ! In a menuPick handler therefore, you don't need any translattion, for example !
And, when building the standalone, RR could move the menuitems because they are recognized by their name and not their label. and so on... What do you think "about" this ?
---------------------------------------
@malte
you wrote: You go with the english version and put an empty german.lproj folder into the app bundle. The translation is managed by the OS then.
Very interesting ! Could you tell us how it works ? Or where to find some documentation on this ?
Thanks
Eric
France
(excuse-me, my english is not so good !)
You all give me some trick !
---------------------------------------
@marielle Bonjour Marielle, Merci !
you wrote (#3) :
I assume you know of the existence of a XML library. Is it that you would be after a script that allows for the serialization and deserialization of an interface and its elements
Yes ! I like this approch with setprop and xml.
One benefit of gathering all translation items into an external file (XML for ex.) is that you have all information in one place and simply available to the translator. On the contrary, using customprops can make you forget some objets, and require people that do translation (not necessary the developper) to go inside your app.
(#4) BvG (above) have describe the problem more clearly than I did
---------------------------------------
@xApple
your changeLanguage handler is interesting, but with a small "tuning". I mean :
I think all btns do not need to have their label translated, all fld contents also do not need tanslation. I've build some apps for teaching Internet technologies to french children and of course all the material MUST NOT be automatically translated !
So, a systematic automatic localization is not, in my mind, always needed !
Objets would have to be localized only if they own some special custom prop. For example, a btn label is to be localized if the btn have a "label.fr" property (that contains the translated label, of course)
---------------------------------------
@BvG
For translation of quoted strings I used to replace these strings with a call to a translation function :
Answer LZ("Stack 1.Cd 1.Answer 2") -- "Press Button 1"
Put LZ("Stack 1.Cd 2.Fld 1") into x; put x into field 1 -- "Something is nice"
send "mouseUp" to button "Press me" -- in this case, "Press me" could be the name of the btn, not its label, so no localization needed here (except for the label)
I always put the original english string as a comment ! For readability.
My localization function LZ retrieves the string either in some custom props of a localized pref stack (that can be modified even after the app has become a standalone) either in an XML file.
To identify the string to retrieve, I used to name them with some kind of dot path (see example). This allows to use translations adapted to contexts. For example, the english word "to" is translated in "vers" or "Ã " french words according the the context !
A bad practice (I've seen it in some PHP apps like source forge webcalendar) would be to use the form ...LZ("Press Button 1")... for the reason mentioned just above ; and because the translator cannot know where the string is used and how it can be well translated !
Last, but not least : I can retrive, in all my scripts, the places where translation/localization has been put : I do a find with "LZ("
The most important response I was waiting for is about "About..." or "A propos..."
I'm unhappy it seems there is none !
A solution (suggestion to RR team !) would be to have a name AND a label for menus and menutitems ! Like it is for btns. So, you could easily refer to those objects withing your scripts, whatever their names are ! In a menuPick handler therefore, you don't need any translattion, for example !
And, when building the standalone, RR could move the menuitems because they are recognized by their name and not their label. and so on... What do you think "about" this ?
---------------------------------------
@malte
you wrote: You go with the english version and put an empty german.lproj folder into the app bundle. The translation is managed by the OS then.
Very interesting ! Could you tell us how it works ? Or where to find some documentation on this ?
Thanks
Eric
France
The Erikoded Frenchy
La logique est le dernier refuge des gens sans imagination
Oscar Wilde :: Logic is the last refuge of the unimaginative
La logique est le dernier refuge des gens sans imagination
Oscar Wilde :: Logic is the last refuge of the unimaginative
Hi Eric,Eric_Taquet wrote: The most important response I was waiting for is about "About..." or "A propos..."
I'm unhappy it seems there is none !
A solution (suggestion to RR team !) would be to have a name AND a label for menus and menutitems ! Like it is for btns. So, you could easily refer to those objects withing your scripts, whatever their names are ! In a menuPick handler therefore, you don't need any translattion, for example !
And, when building the standalone, RR could move the menuitems because they are recognized by their name and not their label. and so on... What do you think "about" this ?
---------------------------------------
@malte
you wrote: You go with the english version and put an empty german.lproj folder into the app bundle. The translation is managed by the OS then.
Very interesting ! Could you tell us how it works ? Or where to find some documentation on this ?
Thanks
Eric
France
about and help are managed by OS X. If you open an app that is multilingual, you will see some folders in there that end with the extension .lproj .
If you put an empty folder in there that has the correct name for your language, menu items that get translated by the OS will get translated automagically.
German.lproj , French.lproj, Dutch.lproj etc.
You will need to control click the application bundle, choose "Show package contents" from the popup menu, navigate to Contents->Resources and place the folders there. (See Preview.app for reference)
Hope that helps,
Malte
Indeed, my script as I gave it to you, does nothing on buttons or fields that do not contain a localized string.Eric_Taquet wrote:Thx everybody !
your changeLanguage handler is interesting, but with a small "tuning". I mean :
I think all btns do not need to have their label translated, all fld contents also do not need tanslation. I've build some apps for teaching Internet technologies to french children and of course all the material MUST NOT be automatically translated !
So, a systematic automatic localization is not, in my mind, always needed !
Objets would have to be localized only if they own some special custom prop. For example, a btn label is to be localized if the btn have a "label.fr" property (that contains the translated label, of course)
-
- Posts: 29
- Joined: Wed Feb 14, 2007 3:26 pm
- Location: FRANCE, Villeneuve d'Ascq
I'm sorry xApple, I didn't read it carefully enough !xApple wrote:Indeed, my script as I gave it to you, does nothing on buttons or fields that do not contain a localized string.
Thank you very much !
The Erikoded Frenchy
La logique est le dernier refuge des gens sans imagination
Oscar Wilde :: Logic is the last refuge of the unimaginative
La logique est le dernier refuge des gens sans imagination
Oscar Wilde :: Logic is the last refuge of the unimaginative
Re: Localization : how to
I proposed that the GUI of Livecode could be localised. So we could translate somewhere the terms and we would have our French livecode.
Please, leave a comment on this post.
Please, leave a comment on this post.