mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

LanguageManager translation support improvements #572

Open mgarin opened 4 years ago

mgarin commented 4 years ago

There are multiple cases right now when specifying translation key for a component is very obscure and/or doesn't support data objects.

Part of the problem lies in the fact that translation is specified as a String instead of separate class like StyleId for StyleManager. That should be changed to clarify when actual translation is provided and when a simple plain text needs to be used. Something like LanguageKey can be used for that.

On top of that it might allow having a translation structure when something like this key:

LanguageKey.of ( "some.panel" )

Is set into a container and then another key:

LanguageKey.of ( "button", container )

Is used for other component referencing that container to build translation structure:

<Dictionary prefix="some.panel" xmlns="http://weblookandfeel.com/Dictionary">
    <Dictionary prefix="button">
        <record key="skin">
            <value lang="en">Button</value>
            <value lang="ru">Кнопка</value>
        </record>
    </Dictionary>
</Dictionary>

Some of the String constructors for components will still remain as a simple version of language setup, but it is optional and can be explicitly disabled in UILanguageManager even now.