/** * Sets the selected locale on the installation data. * * @param code the locale ISO code */ public void propagateLocale(String code) { try { locales.setLocale(code); Locale newLocale = locales.getLocale(); Locale.setDefault(newLocale); installData.setLocale(locales.getLocale(), locales.getISOCode()); installData.setMessages(locales.getMessages()); AbstractInstallDataProvider.addCustomLangpack(installData, locales); } catch (Exception exception) { logger.log(Level.SEVERE, exception.getMessage(), exception); } } }
/** * Constructs a {@code Languages}. * * @param locales the locales * @param installData the installation data * @param font the font to verify that language display names can be displayed. May be {@code null} */ public Languages(Locales locales, ConsoleInstallData installData) { DisplayNameCollector collector = new DefaultDisplayNameCollector(); for (String code : locales.getISOCodes()) { collector.addDisplayName(code, locales.getLocale(code), displayNames); } }
/** * Load a default locale in the installData * * @param installData the installation data * @param locales the supported locales * @throws IOException for any I/O error */ protected void loadDefaultLocale(AutomatedInstallData installData, Locales locales) { Locale locale = locales.getLocale(); if (locale != null) { installData.setInstallationRecord(new XMLElementImpl("AutomatedInstallation")); installData.setLocale(locale, locales.getISOCode()); installData.setMessages(locales.getMessages()); } }
/** * Returns the locale-specific messages. * * @return the messages */ public Messages getMessages() { return locales.getMessages(); }
/** * Returns the locale's ISO3 language code. * * @return the current language code, or {@code null} if no locale is set */ public String getLocale() { if (locales != null) { Locale locale = locales.getLocale(); return (locale != null) ? locale.getISO3Language() : null; } return null; }
/** * Displays the dialog. * * @throws Exception for any error */ public void initLangPack() throws Exception { // Loads the suitable langpack switch (locales.getLocales().size()) { case 0: // nothing to do at this point break; case 1: // propagate the specified language String codeOfUniqueLanguage = displayNames.keySet().iterator().next(); propagateLocale(codeOfUniqueLanguage); break; default: super.getOwner().setVisible(false); setVisible(true); } }
/** * Sets the locale. * * @param code the locale ISO language code * @throws IzPackException if the locale isn't supported */ public void setLocale(String code) { Locales locales = getComponent(Locales.class); locales.setLocale(code); }
/** * Provides an {@link Messages}. * * @param locales the locales * @return the messages from the current locale */ public Messages provide(Locales locales) { return locales.getMessages(); } }
Locale locale = (locales != null) ? locales.getLocale() : null; String country = null; String language = null;
switch (locales.getLocales().size()) { case 0: break;
/** * Sets the selected locale on the installation data. * * @param code the locale ISO code */ public void propagateLocale(String code) { try { locales.setLocale(code); Locale newLocale = locales.getLocale(); Locale.setDefault(newLocale); JComponent.setDefaultLocale(newLocale); SwingUtilities.updateComponentTreeUI(this); installData.setLocale(locales.getLocale(), locales.getISOCode()); installData.setMessages(locales.getMessages()); AbstractInstallDataProvider.addCustomLangpack(installData, locales); // Configure buttons after locale has been loaded installData.configureGuiButtons(); } catch (Exception exception) { logger.log(Level.SEVERE, exception.getMessage(), exception); } }
/** * Changes the quit button text. If <tt>text</tt> is null, the default quit text is used. * * @param text text to be used for changes */ public void setQuitButtonText(String text) { if (text == null) { Messages messages = locales.getMessages(); text = messages.get("installer.quit"); } navigator.setQuitText(text); }
for (String code : locales.getISOCodes()) collector.addDisplayName(code, locales.getLocale(code), displayNames);
installData.setInstallationRecord(installRecord); String code = installRecord.getAttribute("langpack", "eng"); locales.setLocale(code); installData.setMessages(locales.getMessages()); installData.setLocale(locales.getLocale(), locales.getISOCode()); installData.setMediaPath(mediaPath);
/** * Creates a new messages instance from the named resource that inherits the current messages. * * @param name the messages resource name * @return the messages */ @Override public Messages newMessages(String name) { Messages child = locales.getMessages(name); Messages result = new LocaleDatabase(this, locales); result.add(child); return result; }
/** * Add the contents of a custom langpack to the default langpack, if it exists. * * @param installData the install data to be used */ public static void addCustomLangpack(AutomatedInstallData installData, Locales locales) { // We try to load and add a custom langpack. try { installData.getMessages().add(locales.getMessages(Resources.CUSTOM_TRANSLATIONS_RESOURCE_NAME)); logger.fine("Found custom langpack for " + installData.getLocaleISO3()); } catch (ResourceNotFoundException exception) { logger.fine("No custom langpack for " + installData.getLocaleISO3() + " available"); } }
/** * Writes uninstall data if it is required. * <p/> * An error message will be displayed if the write fails. * * @return <tt>true</tt> if uninstall data was written successfully or is not required, otherwise <tt>false</tt> */ private boolean writeUninstallData() { boolean result = true; if (uninstallDataWriter.isUninstallRequired()) { result = uninstallDataWriter.write(); if (!result) { Messages messages = locales.getMessages(); String title = messages.get("installer.error"); String message = messages.get("installer.uninstall.writefailed"); JOptionPane.showMessageDialog(this, message, title, JOptionPane.ERROR_MESSAGE); } } return result; }
private void performHeadingCounter(IzPanelView panel) { if (headingCounterComponent != null) { int curPanelNo = panels.getVisibleIndex(panel); int visPanelsCount = panels.getVisible(); Messages messages = locales.getMessages(); String message = String.format( "%s %d %s %d", messages.get("installer.step"), curPanelNo + 1, messages.get("installer.of"), visPanelsCount ); if (headingCounterComponent instanceof JProgressBar) { updateProgressBar(visPanelsCount, curPanelNo + 1, message); } else { updateProgressCounter(message); } } }
Messages messages = locales.getMessages(); navigator.updateButtonText(messages);
Messages messages = locales.getMessages();