Search in sources :

Example 1 with Language

use of com.jsql.view.swing.dialog.translate.Language in project jsql-injection by ron190.

the class Menubar method initializeMenuI18nContribution.

private JMenu initializeMenuI18nContribution() {
    var menuI18nContribution = new JMenu(I18nUtil.valueByKey("MENUBAR_COMMUNITY_HELPTRANSLATE"));
    I18nViewUtil.addComponentForKey("MENUBAR_COMMUNITY_HELPTRANSLATE", menuI18nContribution);
    // Render the About dialog behind scene
    final var dialogTranslate = new DialogTranslate();
    class ActionTranslate implements ActionListener {

        private Language language;

        ActionTranslate(Language language) {
            this.language = language;
        }

        @Override
        public void actionPerformed(ActionEvent arg0) {
            dialogTranslate.initializeDialog(this.language);
            // Center the dialog
            if (!dialogTranslate.isVisible()) {
                dialogTranslate.setSize(640, 460);
                dialogTranslate.setLocationRelativeTo(MediatorHelper.frame());
                dialogTranslate.getRootPane().setDefaultButton(dialogTranslate.getButtonSend());
            }
            dialogTranslate.setVisible(true);
        }
    }
    var formatMenuItemUTF8 = "<html><span style=\"font-family:'%s'\">%s</span>...</html>";
    this.itemIntoHindi = new JMenuItem(String.format(formatMenuItemUTF8, UiUtil.FONT_NAME_MONO_ASIAN, new Locale("hi").getDisplayLanguage(new Locale("hi"))), UiUtil.ICON_FLAG_HI);
    this.itemIntoArabic = new JMenuItem(String.format(formatMenuItemUTF8, UiUtil.FONT_NAME_MONO_ASIAN, new Locale("ar").getDisplayLanguage(new Locale("ar"))), UiUtil.ICON_FLAG_AR);
    this.itemIntoRussia = new JMenuItem(new Locale("ru").getDisplayLanguage(new Locale("ru")) + "...", UiUtil.ICON_FLAG_RU);
    this.itemIntoChina = new JMenuItem(String.format(formatMenuItemUTF8, UiUtil.FONT_NAME_MONO_ASIAN, new Locale("zh").getDisplayLanguage(new Locale("zh"))), UiUtil.ICON_FLAG_ZH);
    this.itemIntoFrench = new JMenuItem(new Locale("fr").getDisplayLanguage(new Locale("fr")) + "...", UiUtil.ICON_FLAG_FR);
    this.itemIntoTurkish = new JMenuItem(new Locale("tr").getDisplayLanguage(new Locale("tr")) + "...", UiUtil.ICON_FLAG_TR);
    this.itemIntoCzech = new JMenuItem(new Locale("cs").getDisplayLanguage(new Locale("cs")) + "...", UiUtil.ICON_FLAG_CS);
    this.itemIntoDutch = new JMenuItem(new Locale("nl").getDisplayLanguage(new Locale("nl")) + "...", UiUtil.ICON_FLAG_NL);
    this.itemIntoGerman = new JMenuItem(new Locale("de").getDisplayLanguage(new Locale("de")) + "...", UiUtil.ICON_FLAG_DE);
    this.itemIntoIndonesian = new JMenuItem(new Locale("in", "ID").getDisplayLanguage(new Locale("in", "ID")) + "...", UiUtil.ICON_FLAG_IN_ID);
    this.itemIntoItalian = new JMenuItem(new Locale("it").getDisplayLanguage(new Locale("it")) + "...", UiUtil.ICON_FLAG_IT);
    this.itemIntoSpanish = new JMenuItem(new Locale("es").getDisplayLanguage(new Locale("es")) + "...", UiUtil.ICON_FLAG_ES);
    this.itemIntoPortuguese = new JMenuItem(new Locale("pt").getDisplayLanguage(new Locale("pt")) + "...", UiUtil.ICON_FLAG_PT);
    this.itemIntoPolish = new JMenuItem(new Locale("pl").getDisplayLanguage(new Locale("pl")) + "...", UiUtil.ICON_FLAG_PL);
    this.itemIntoRomanian = new JMenuItem(new Locale("ro").getDisplayLanguage(new Locale("ro")) + "...", UiUtil.ICON_FLAG_RO);
    this.itemIntoTamil = new JMenuItem(new Locale("ta").getDisplayLanguage(new Locale("ta")) + "...", UiUtil.ICON_FLAG_LK);
    this.itemIntoJapanese = new JMenuItem(String.format(formatMenuItemUTF8, UiUtil.FONT_NAME_MONO_ASIAN, new Locale("ja").getDisplayLanguage(new Locale("ja"))), UiUtil.ICON_FLAG_JA);
    this.itemIntoKorean = new JMenuItem(String.format(formatMenuItemUTF8, UiUtil.FONT_NAME_MONO_ASIAN, new Locale("ko").getDisplayLanguage(new Locale("ko"))), UiUtil.ICON_FLAG_KO);
    this.itemIntoSwedish = new JMenuItem(new Locale("se").getDisplayLanguage(new Locale("se")) + "...", UiUtil.ICON_FLAG_SE);
    this.itemIntoFinnish = new JMenuItem(new Locale("fi").getDisplayLanguage(new Locale("fi")) + "...", UiUtil.ICON_FLAG_FI);
    var itemIntoOther = new JMenuItem(I18nUtil.valueByKey("MENUBAR_COMMUNITY_ANOTHERLANGUAGE"));
    I18nViewUtil.addComponentForKey("MENUBAR_COMMUNITY_ANOTHERLANGUAGE", itemIntoOther);
    this.itemIntoArabic.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    this.itemIntoFrench.setName("itemIntoFrench");
    Stream.of(this.itemIntoFrench, this.itemIntoSpanish, this.itemIntoSwedish, this.itemIntoFinnish, this.itemIntoTurkish, this.itemIntoCzech, this.itemIntoRomanian, this.itemIntoItalian, this.itemIntoPortuguese, this.itemIntoArabic, this.itemIntoPolish, this.itemIntoRussia, this.itemIntoChina, this.itemIntoGerman, this.itemIntoIndonesian, this.itemIntoJapanese, this.itemIntoKorean, this.itemIntoHindi, this.itemIntoDutch, this.itemIntoTamil, new JSeparator(), itemIntoOther).forEach(menuI18nContribution::add);
    Stream.of(new SimpleEntry<>(this.itemIntoHindi, Language.HI), new SimpleEntry<>(this.itemIntoArabic, Language.AR), new SimpleEntry<>(this.itemIntoRussia, Language.RU), new SimpleEntry<>(this.itemIntoChina, Language.ZH), new SimpleEntry<>(this.itemIntoFrench, Language.FR), new SimpleEntry<>(this.itemIntoTurkish, Language.TR), new SimpleEntry<>(this.itemIntoCzech, Language.CS), new SimpleEntry<>(this.itemIntoGerman, Language.DE), new SimpleEntry<>(this.itemIntoRomanian, Language.RO), new SimpleEntry<>(this.itemIntoTamil, Language.TA), new SimpleEntry<>(this.itemIntoDutch, Language.NL), new SimpleEntry<>(this.itemIntoIndonesian, Language.IN_ID), new SimpleEntry<>(this.itemIntoItalian, Language.IT), new SimpleEntry<>(this.itemIntoSpanish, Language.ES), new SimpleEntry<>(this.itemIntoPortuguese, Language.PT), new SimpleEntry<>(this.itemIntoPolish, Language.PL), new SimpleEntry<>(this.itemIntoKorean, Language.KO), new SimpleEntry<>(this.itemIntoJapanese, Language.JA), new SimpleEntry<>(this.itemIntoSwedish, Language.SE), new SimpleEntry<>(this.itemIntoFinnish, Language.FI), new SimpleEntry<>(itemIntoOther, Language.OT)).forEach(entry -> entry.getKey().addActionListener(new ActionTranslate(entry.getValue())));
    return menuI18nContribution;
}
Also used : Locale(java.util.Locale) Language(com.jsql.view.swing.dialog.translate.Language) ActionListener(java.awt.event.ActionListener) DialogTranslate(com.jsql.view.swing.dialog.DialogTranslate) ActionEvent(java.awt.event.ActionEvent) SimpleEntry(java.util.AbstractMap.SimpleEntry) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JSeparator(javax.swing.JSeparator)

Aggregations

DialogTranslate (com.jsql.view.swing.dialog.DialogTranslate)1 Language (com.jsql.view.swing.dialog.translate.Language)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 Locale (java.util.Locale)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 JSeparator (javax.swing.JSeparator)1