In article <887E6B64-97BA-11D8-9038-000502FDD5CC / mac.com>, Mark Hubbart <discord / mac.com> wrote: > >On Apr 26, 2004, at 11:09 AM, Phil Tomson wrote: > >> I'm developing a GUI app using Ruby and FLTK. One of the requirements >> that's come up lately is that this app should be 'localizable'. I'm >> trying >> to figure out approaches for doing this as I design the app. >> >> The approach I'm thinking of is to have some seperate file, maybe in >> XML, >> that would contain all of the text which is used for things like button >> labels, output messages, etc. Then to support different languages all >> the >> customer would have to do is include a different language specific >> file. >> >> These files might look something like: >> >> [...] >> >> So, if they wanted to make a Japanese version of the app, they would >> replace each of the strings above with their Japanese counterparts. >> While it seems a bit heavy, I'm thinking an XML approach would be good >> for >> a couple of reasons: >> 1) this localization will probably be taking place long after I'm gone >> (this is a contract job) and XML is widely known and understood. >> 2) it's easy to extract data from it using REXML >> >> >> Does this seem like a reasonable approach? >> >> Has anyone used alternate approaches? > >You might look at Apple/NextStep's approach to localization. (probably >others use it too) Basically, there's a file that maps english text to >the translated text. Then, anywhere in the program where a particular >english string is used, it checks for a translation to the appropriate >language. > >So to do this in ruby, you might have a pig-latin translation file, >using yaml: > >--- >Enter text here: Enterway exttay erehay >Type "yes" to continue: Ypetay "yes" otay ontinuecay > >Then write a small class: > > class Localization > def initialize(filename) > # load yaml data from file to a hash > # stored in @translations > end > def [](text) > @translations[text] || text > end > end > >localization files are automatically generated for english, that >include all the string literals from the source code. I like this idea. However, I'm not clear on how the localization files are automatically generated, can you provide more details? >For the english >files, they just map each string to itself. But then you can easily >hand the file over for translation, and add the new one in. yes, this seems like a good route to take, even if I can't automatically generate thee localization files and knowledge of YAML isn't really an issue because the file format is rather self-explanatory. Phil