This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 195136 - i18n generated code for enabling runtime l10n in forms
Summary: i18n generated code for enabling runtime l10n in forms
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-07 18:38 UTC by nbantonio
Modified: 2011-12-21 19:25 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nbantonio 2011-02-07 18:38:46 UTC
I18 tools generated code disables runtime l10n in forms created with GUIBuilder. Many professional applications require runtime l10n. 

Currently ResourceBundle is instantiated in 'initComponents()' and l10n is performed at form instantiation time. Besides there is no way of specifying the Locale, it will always be 'Locale.getDefault()'. 

I've been forced to set the default Locale in my application (or start JVM setting system properties) and I don't consider this as a good practice.

Enhancements proposed:

1. Provide the form developer some means of specifying the way ResourceBundle will be instantiated. This way the developer will be able to provide the specific Locale for l10n, instead of using defaults. 

For instance, in "Form Properties" panel, "Resources and Internationalization" section, add: 'Code for instantiating ResourceBundle', defaulting to current generated code. Examples:

- Code for instantiating ResourceBundle: java.util.ResourceBundle.getBundle("examples/Antenna"); //current default

- Code for instantiating ResourceBundle: ResourceBundle.getBundle("examples/Antenna", MyApp.getConfig().getLocale());

- Code for instantiating ResourceBundle: ResourceBundle.getBundle("examples/Antenna", MyResourceBundleFactory.create());

- Code for instantiating ResourceBundle: ResourceBundle.getBundle(MyResourceBundleFactory.create(MyForm.class));


2. Get l10n code out of 'initComponents()'. This way l10n code can be called at runtime. l10n code will be called from 'initComponents()'. For instance:

public void localize(ResourceBundle rb) {
    setTitle(bundle.getString("ContactEditor.title"));
    jLabel1.setText(bundle.getString("ContactEditor.jLabel1.text"));    
    /*     all l10n code here     */
}

private void initComponents() {
    /* instantiate and layout components   */

    //localize({ResourceBundle user instantiation code});
    //e.g.
    localize(ResourceBundle.getBundle("bundle", MyApp.getConfig().getLocale()));
}
Comment 1 Iksa 2011-12-21 19:24:16 UTC
The proposed workaround to set the default locale prior to calling initComponents does not work for applets as they do not have permission to change it.