lizongbo

[bug]: the Spark's language plugin don't list all language menus

Discussion created by lizongbo on Jan 15, 2008
Latest reply on Jan 15, 2010 by Alexsandr

 

when I want to add the QQtransport code for Spark,I found a bug for language plugi.

 

 

I got the code from svn , http://svn.igniterealtime.org/svn/repos/spark/trunk

 

 

code version is : 9772 .

 

 

spark_lc01.jpg is the bug for .

 

 

Then I read the code ,and I found that why bug happened.

 

 

In   the method "addLanguage ",

 

 

It used " if (locale.getLanguage().equals(language)) "  to check Locale.

 

 

but getLanguage() for "zh_CN"  and "xx_YY",only ge "zh" or "xx".

 

 

also ,locale.getDisplayLanguage(locale) for "zn_CN" is same of for "zn_TW".

 

 

My code for fix this bug:

 

 

 

 

   private void addLanguage(String language) {

 

        for (final Locale locale : locales) {

 

            if (locale.toString().equals(language)) {//fix it,by lizongbo

 

                Action action = new AbstractAction() {

 

                    public void actionPerformed(ActionEvent e) {

 

                        final LocalPreferences preferences = SettingsManager.

 

                                getLocalPreferences();

 

                        preferences.setLanguage(locale.toString());// fix it ,by lizongbo

 

                        SettingsManager.saveSettings();

 

 

 

                        int ok = JOptionPane.showConfirmDialog(SparkManager.

 

                                getMainWindow(),

 

                                Res.getString("message.restart.required"),

 

                                Res.

 

                                getString("title.confirmation"),

 

                                JOptionPane.YES_NO_OPTION);

 

                        if (ok == JOptionPane.YES_OPTION) {

 

                            SparkManager.getMainWindow().shutdown();

 

                        }

 

                    }

 

                };

 

                // change the menu label ,by lizongbo

 

                String label = locale.getDisplayLanguage(locale);

 

                if (locale.getDisplayCountry(locale) != null &&

 

                    locale.getDisplayCountry(locale).trim().length() > 0) {

 

                    label = label + "-" + locale.getDisplayCountry(locale).trim();

 

                }

 

                action.putValue(Action.NAME, label);

 

                languageMenu.add(action);

 

                break;

 

            }

 

        }

 

    }

 

 

/code

 

 

 

 

 

after fix the bug ,we can see all of the available language menus.

 

 

see: spark_lc02.jpg

 

 

 

 

 

 

 

 

 

 

 

Attachments

Outcomes