appfoundation internationalization usages

I’m wondering whether I’m missing a way to use internationalization that’s easier on the performance and perhaps on the code too

I have this menu:


public class MainMenu extends MenuBar {
    private MenuBar.MenuItem newPrediction;
...
    public MainMenu() {
        newPrediction = addItem(Lang.getMessage("NEW_PREDICTION"), null);
        ...
    }
}

Simplest way to change language, I have to remake and add the whole menu to the application, but that uses the most resources.

Another way would be to make a method in the menu object that sets every text for every menu item, keep a reference to the added menu and call that method from it on every locale change, which is easier on the resources than the last somewhat.


My idea is that internationalization should be somehow built in the String object, so when it’s fetched (through an accesor), it would return the proper internationalized char sequence from the loaded static cache. This way, the developer doesn’t need to write extra procedures to handle locale change events.


Another tehnique would be to have all references point to an internationalized text reference, and on locale change, that main reference would be changed with the reference of the right internationalized text (corresponding to the new locale), having the effect of all the other references dereferencing the new locale internationalized text instead. AFAIK that’s only possible with pointers which are not available in Java. C# has pointers. However an intermediary object could perform the task of the main reference which is to represent the right internationalized text, however that would imply some code changes on the objects referencing that main object, such as calling a method to return the right reference every time it’s needed, which would check whether the locale has change and return the reference accordingly. The final effect being that the developer doesn’t need to write extra procedures to handle locale change events.