use of org.zaproxy.zap.view.LocaleDialog in project zaproxy by zaproxy.
the class GuiBootstrap method setupLocale.
/**
* Setups ZAP's and GUI {@code Locale}, if not previously defined. Otherwise it's determined automatically or, if not
* possible, by asking the user to choose one of the supported locales.
*
* @param options ZAP's options, used to check if a locale was already defined and save it if not.
* @see #setDefaultViewLocale(Locale)
* @see Constant#setLocale(String)
*/
private void setupLocale(OptionsParam options) {
// Prompt for language if not set
String locale = options.getViewParam().getConfigLocale();
if (locale == null || locale.length() == 0) {
// Dont use a parent of the MainFrame - that will initialise it
// with English!
final Locale userloc = determineUsersSystemLocale();
if (userloc == null) {
// Only show the dialog, when the user's language can't be
// guessed.
setDefaultViewLocale(Constant.getSystemsLocale());
final LocaleDialog dialog = new LocaleDialog(null, true);
dialog.init(options);
dialog.setVisible(true);
} else {
options.getViewParam().setLocale(userloc);
}
setDefaultViewLocale(createLocale(options.getViewParam().getLocale().split("_")));
Constant.setLocale(Model.getSingleton().getOptionsParam().getViewParam().getLocale());
try {
options.getViewParam().getConfig().save();
} catch (ConfigurationException e) {
logger.warn("Failed to save locale: ", e);
}
}
}
Aggregations