Internationalisation
Alex Rice
alex at mindlube.com
Mon Jan 6 11:59:03 EST 2003
On Friday, January 3, 2003, at 03:29 PM, Igor Couto wrote:
> Or have people found other ways/approaches to internationalising their
> apps?
>
> All suggestions GREATLY appreciated!
Consider the following for the brainstorming only. Cocoa, Apple's
Objective-C application framework, has the most elegant
internationalization method I've ever seen in a programming
environment. It might not even be applicable to Revolution. However,
maybe people will want to dig deeper and get some ideas for the ideal
way to do it in Revolution.
Cocoa applications that support Internationalization are automatically
and fully translated into the appropriate language at run-time,.
Everything can be Internationalized, from graphics to on-screen text to
messages and programmatic content. Messages coming back from the OS are
internationalized. Date, time, and currency formatting are easily
formatted to user's international preferences.
A Cocoa app is a bundle, which is just a folder containing resources in
addition to the binary app itself. The Resources folder can be broken
down into subfolders for each supported language. Each language
subfolder can have "nib" files and property list files files, and other
resources.
A nib file is an archive of user-interface objects created by Interface
Builder.app. It contains the layouts and connections among Windows,
Views, Buttons, etc. In contains the entire GUI, except parts which are
created programmatically. When the app runs, the "nib" file is
connected to the app itself. The app has "outlets" which are connected
to objects in the nib file. The nib file objects have "actions" and
"delegates" which are connected to objects and methods in the app
itself. So the UI components and the app code are cleanly separated,
but glued together automatically at runtime.
Abstracting out the UI into the nib files also gives you a way to do
some really clean Internationalization. Remember the Resources folder
in the app can have subfolders for each language. There is a command
line tool "nibtool" which can be used to extract all the localizable
strings from a nib for sending to translators. nibtool can then merge
the localized strings back into a copy of the nib file.
The programmer doesn't have to do anything in programming code to get
the app to bind with the localized nib file. Once the app is localized
with it's layout of nib files and resources in it's app bundle, the
Cocoa framework handles the rest at app startup.
There are also macros for programmatically getting localized content
out of the app bundle, automatically, like NSLocalizedString(@"some
message here...", nil); This is kind of like Rob's sdbMessage()
function, but if there is not a matching localized string for the
current language, it will use the first parameter to the macro.
Alex Rice, Software Developer
Architectural Research Consultants, Inc.
alrice at ARCplanning.com
alrice at swcp.com
More information about the use-livecode
mailing list