Folks,
As mentioned, attached is a rough outline of how I think a decent localization browser could work. First of all, file in *ONLY* the LocalizationBrowser.cs (we'll come to the other later). Open a workspace and let the fun begin:
* Let's create a new locale and install it
"Create the locale" myLocale := Locale named: 'MyLanguage'. "Install it" myLocale install. "Print to see if it's installed" Locale current
* Open a localization browser
LocalizationBrowser openBrowser.
It looks just like a regular browser. Now click on 'Kernel-Objects'. You'll see that classes are highlighted differently. The encodings are: * plain: No literal strings whatsoever. * bold: Untranslated literal strings. * italics: Translated literal strings. * bold-italics: Both translated and untranslated strings Now click on Object and get into #errorSubscriptBounds: You will see that the error message is highlighted in red, meaning it is unchanged from the default locale. Get in there and replace it with something like (I'm doing it in German):
'Index ueberschritten: '.
Accept it. Note that the string changes to blue, indicating that the string is translated. (BTW, if you try to do *anything* but changing the string you'll get an error message -- try it). Evaluate the following expression:
#() at: 3.
You'll get some pretty appropriate error message. Please KEEP THE PREDEBUG-WINDOW OPEN.
[The following is exclusively for G-ran ;-] CMD-Click a number of times on the 'Proceed' string until you get down to the string morph containing 'Proceed'. Click on the debug handle, and choose the last entry saying 'localize contents'. Wait a little and a message set with tons of messages containing 'Proceed' will pop up. Choose the first one that has an exclusive literal string saying 'Proceed' (on my machine that's Debugger>>optionalButtonPairs - note that for purposes of the demo it is important that you do *NOT* change Debugger>>preDebugButtonQuads ;-) Change that string into something like 'Weiter' and accept. Close the old pre-debugger and evaluate again:
#() at: 3.
You'll notice that the 'Proceed' button is still there although we changed it someplace else. This is because changes are not automatically broadcast (it just takes too long) so we have to do it explicitly. Evaluate:
Locale current reInstall.
And now evaluate again:
#() at: 3.
and now it's there. Okay, that way you can go through the system and localize all its contents. From time to time you may want to reInstall your locale to make sure you're seeing all the changes you did. For storing your localized strings you can evaluate:
Locale current storeStringTable.
Which will store all the localized strings in a compressed table (which you can uncompress and hand-edit if you like; and that's specifically for Richard ;-)
If you wish to switch back to the default locale just evaluate:
Locale current unInstall.
and to see that this really works, let's just once more evaluate:
#() at: 3.
and also that we can still switch back:
(Locale named: 'MyLanguage') install. #() at: 3.
Now some more fun. Load the LocaleDeutsch.cs which is an example for a locale that contains more than just strings. To install it evaluate:
(Locale named: 'Deutsch') install.
and one of the fun things you can do now is to ask a questions like
SmallInteger maxVal asWords. (Locale named: 'Deutsch') uninstall. SmallInteger maxVal asWords.
(heh, heh). Note that this is JUST A DEMO so spare yourself any complains about all that stuff that's missing - I know it as least as well as you do ;-)
But comments are nevertheless appreciated.
Cheers, - Andreas
squeak-dev@lists.squeakfoundation.org