use of org.zaproxy.zap.view.ViewLocale in project zaproxy by zaproxy.
the class LocaleUtils method getAvailableViewLocales.
/**
* Returns a list of {@code ViewLocale}s, sorted by display name, of the default language and available translations.
*
* @return the {@code ViewLocale}s of the default language and available translations.
* @see ViewLocale
* @since 2.4.0
*/
public static List<ViewLocale> getAvailableViewLocales() {
List<String> locales = readAvailableLocales();
List<ViewLocale> localesUI = new ArrayList<>();
if (!locales.isEmpty()) {
for (String locale : locales) {
localesUI.add(new ViewLocale(locale, getLocalDisplayName(locale)));
}
Collections.sort(localesUI, new Comparator<ViewLocale>() {
@Override
public int compare(ViewLocale o1, ViewLocale o2) {
return o1.toString().compareTo(o2.toString());
}
});
}
// Always put English at the top
localesUI.add(0, new ViewLocale(DEFAULT_LOCALE, getLocalDisplayName(DEFAULT_LOCALE)));
return localesUI;
}
use of org.zaproxy.zap.view.ViewLocale in project zaproxy by zaproxy.
the class OptionsLangPanel method saveParam.
@Override
public void saveParam(Object obj) throws Exception {
OptionsParam options = (OptionsParam) obj;
ViewLocale selectedLocale = (ViewLocale) localeSelect.getSelectedItem();
if (selectedLocale != null) {
options.getViewParam().setLocale(selectedLocale.getLocale());
}
}
use of org.zaproxy.zap.view.ViewLocale in project zaproxy by zaproxy.
the class OptionsLangPanel method initParam.
@Override
public void initParam(Object obj) {
OptionsParam options = (OptionsParam) obj;
ViewLocale locale = LocaleUtils.getViewLocale(options.getViewParam().getLocale());
localeSelect.setSelectedItem(locale);
}
use of org.zaproxy.zap.view.ViewLocale in project zaproxy by zaproxy.
the class OptionsLocalePanel method saveParam.
@Override
public void saveParam(Object obj) throws Exception {
OptionsParam options = (OptionsParam) obj;
ViewLocale selectedLocale = (ViewLocale) localeSelect.getSelectedItem();
if (selectedLocale != null) {
options.getViewParam().setLocale(selectedLocale.getLocale());
}
}
use of org.zaproxy.zap.view.ViewLocale in project zaproxy by zaproxy.
the class OptionsLocalePanel method getLocaleSelect.
private JComboBox<ViewLocale> getLocaleSelect() {
if (localeSelect == null) {
localeSelect = new JComboBox<>();
for (ViewLocale locale : LocaleUtils.getAvailableViewLocales()) {
localeSelect.addItem(locale);
}
localeSelect.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Change to use the selected language in the dialog
ViewLocale selectedLocale = (ViewLocale) localeSelect.getSelectedItem();
if (selectedLocale != null) {
Constant.setLocale(selectedLocale.getLocale());
localeLabel.setText(Constant.messages.getString("locale.options.label.language"));
localeChangeLabel.setText(Constant.messages.getString("locale.options.label.change"));
}
}
});
}
return localeSelect;
}
Aggregations