mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-02 11:54:36 +00:00
Multilanguage support
Czech language added
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.Configuration;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SelectLanguageDialog extends AppDialog implements ActionListener {
|
||||
|
||||
JComboBox<Language> languageCombobox = new JComboBox<>();
|
||||
public String languageCode = null;
|
||||
private String languages[] = new String[]{"en", "cs"};
|
||||
|
||||
public SelectLanguageDialog() {
|
||||
setSize(350, 130);
|
||||
Container cnt1 = getContentPane();
|
||||
JPanel cnt = new JPanel();
|
||||
cnt1.setLayout(new BorderLayout());
|
||||
cnt1.add(cnt, BorderLayout.CENTER);
|
||||
|
||||
|
||||
String currentLanguage = (String) Configuration.getConfig("locale", Locale.getDefault().getLanguage());
|
||||
boolean found = false;
|
||||
int enIndex = 0;
|
||||
for (String code : languages) {
|
||||
String name = new Locale(code).getDisplayName();
|
||||
if (name.length() > 1) {
|
||||
name = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
}
|
||||
if (code.equals("en")) {
|
||||
enIndex = languageCombobox.getItemCount();
|
||||
}
|
||||
languageCombobox.addItem(new Language(code, name));
|
||||
if (code.equals(currentLanguage)) {
|
||||
languageCombobox.setSelectedIndex(languageCombobox.getItemCount() - 1);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
languageCombobox.setSelectedIndex(enIndex);
|
||||
}
|
||||
cnt.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
cnt.setLayout(new BoxLayout(cnt, BoxLayout.Y_AXIS));
|
||||
JLabel langLabel = new JLabel("Language:");
|
||||
langLabel.setAlignmentX(0.5f);
|
||||
cnt.add(langLabel);
|
||||
languageCombobox.setAlignmentX(0.5f);
|
||||
cnt.add(languageCombobox);
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
buttonsPanel.setAlignmentX(0.5f);
|
||||
JButton okButton = new JButton(translate("button.ok"));
|
||||
okButton.setActionCommand("OK");
|
||||
okButton.addActionListener(this);
|
||||
JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.addActionListener(this);
|
||||
buttonsPanel.add(okButton);
|
||||
buttonsPanel.add(cancelButton);
|
||||
cnt.add(buttonsPanel);
|
||||
getRootPane().setDefaultButton(okButton);
|
||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
View.setWindowIcon(this);
|
||||
View.centerScreen(this);
|
||||
setTitle("Select language");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "OK":
|
||||
if (languageCombobox.getSelectedIndex() == -1) {
|
||||
} else {
|
||||
languageCode = ((Language) languageCombobox.getSelectedItem()).code;
|
||||
setVisible(false);
|
||||
}
|
||||
break;
|
||||
case "CANCEL":
|
||||
setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public String display() {
|
||||
setVisible(true);
|
||||
return languageCode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user