The new Safari 5 has arrived with official extension feature. But while I was playing around the extension, I didn’t find a way to make an extension speak multiple languages, just as every Mac applications.
The built-in extension builder in Safari 5 does not provide an option to create multi-language support for an extension, thus I’m trying to make it the way with the validate event.
The validate event happens at the first time when a toolbar button or a contextual menu item is appended to Safari, and anytime you need to change those items with different scenarios. It’s the best opportunity to change their labels or tooltips (only with the toolbar button.)
How to make change to extension items during the validate event is described in Safari Developer Site and the documentation is open to everyone. So you can setup a locale array and change the label of your toolbar button or contextual menu item.
For quick reference of what text you can customize, you may be interested in the following two references:
Too bad for the toolbar item, its paletteLabel is readonly so you cannot change it. Other things like badge, image, label and tooltip are all there for you to customize in runtime. For the contextual menu item, you can change its title property.
Update: the validate event seems to be fired when a toolbar button is appended to the toolbar or change of current tab (e.g, loading another page or opening a new tab.) So if you want to make some immediate change, code it in the command event.