mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
language selection UI
This commit is contained in:
@@ -93,6 +93,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
|||||||
public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID;
|
public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID;
|
||||||
|
|
||||||
public static final String LANGUAGE = "language";
|
public static final String LANGUAGE = "language";
|
||||||
|
public static final String LANGUAGE_DEFAULT = "English";
|
||||||
|
|
||||||
public static final int DND_TOGGLE_STICKY = 0x1;
|
public static final int DND_TOGGLE_STICKY = 0x1;
|
||||||
public static final int DND_TOGGLE_SNAP = 0x40000000;
|
public static final int DND_TOGGLE_SNAP = 0x40000000;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class TranslateUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void configure() {
|
public static void configure() {
|
||||||
String language = ConfigurationManager.getInstance().readString(IPlugInPort.LANGUAGE, "English");
|
String language = ConfigurationManager.getInstance().readString(IPlugInPort.LANGUAGE, IPlugInPort.LANGUAGE_DEFAULT);
|
||||||
if (language != null)
|
if (language != null)
|
||||||
load(language);
|
load(language);
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,8 @@ public class TranslateUtil {
|
|||||||
public static List<String> getAvailableLanguages() {
|
public static List<String> getAvailableLanguages() {
|
||||||
try (Stream<Path> walk = Files.walk(Paths.get(LANG_DIR))) {
|
try (Stream<Path> walk = Files.walk(Paths.get(LANG_DIR))) {
|
||||||
|
|
||||||
return walk.filter(Files::isRegularFile).map(x -> x.toString()).collect(Collectors.toList());
|
return walk.filter(Files::isRegularFile).map(x -> x.getFileName().toString().replaceFirst("[.][^.]+$", ""))
|
||||||
|
.collect(Collectors.toList());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Error fetching available languages");
|
LOG.error("Error fetching available languages");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -22,12 +22,7 @@
|
|||||||
5 band
|
5 band
|
||||||
5PDT
|
5PDT
|
||||||
5PDT (Center OFF)
|
5PDT (Center OFF)
|
||||||
API de complemento
|
|
||||||
API de componentes
|
|
||||||
AWG
|
AWG
|
||||||
Acceder a archivos de usuario
|
|
||||||
Acerca de
|
|
||||||
Actualizaciones recientes
|
|
||||||
C-B-E BJT
|
C-B-E BJT
|
||||||
D-G-S JFET
|
D-G-S JFET
|
||||||
D-G-S MOSFET
|
D-G-S MOSFET
|
||||||
@@ -41,14 +36,13 @@ DP5T
|
|||||||
DPDT
|
DPDT
|
||||||
DPDT (Center OFF)
|
DPDT (Center OFF)
|
||||||
E-B-C BJT
|
E-B-C BJT
|
||||||
Enviar un error
|
English
|
||||||
|
French
|
||||||
G-D-S JFET
|
G-D-S JFET
|
||||||
G-D-S MOSFET
|
G-D-S MOSFET
|
||||||
G-S-D JFET
|
G-S-D JFET
|
||||||
G-S-D MOSFET
|
G-S-D MOSFET
|
||||||
Haz una donación
|
Language
|
||||||
Help
|
|
||||||
Manual de usuario
|
|
||||||
NPN
|
NPN
|
||||||
Nor
|
Nor
|
||||||
Not
|
Not
|
||||||
@@ -56,19 +50,21 @@ Or
|
|||||||
PAF
|
PAF
|
||||||
PCB
|
PCB
|
||||||
PNP
|
PNP
|
||||||
Preguntas más frecuentes
|
|
||||||
Project Cloud
|
Project Cloud
|
||||||
S-G-D JFET
|
S-G-D JFET
|
||||||
S-G-D MOSFET
|
S-G-D MOSFET
|
||||||
SPDT
|
SPDT
|
||||||
SPDT (Center OFF)
|
SPDT (Center OFF)
|
||||||
SPST
|
SPST
|
||||||
Test
|
Spanish
|
||||||
Xnor
|
Xnor
|
||||||
Xor
|
Xor
|
||||||
cm
|
cm
|
||||||
ft
|
ft
|
||||||
in
|
in
|
||||||
|
lang\English.txt
|
||||||
|
lang\French.txt
|
||||||
|
lang\Spanish.txt
|
||||||
mm
|
mm
|
||||||
px
|
px
|
||||||
yd
|
yd
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public enum IconLoader {
|
|||||||
Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
|
Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
|
||||||
JarBeanInto("jar_bean_into.png"), GraphEdgeDirected("graph_edge_directed.png"), LaserPointer("laserpointer.png"), TapeMeasure("tape_measure1.png"),
|
JarBeanInto("jar_bean_into.png"), GraphEdgeDirected("graph_edge_directed.png"), LaserPointer("laserpointer.png"), TapeMeasure("tape_measure1.png"),
|
||||||
Elements("elements1.png"), GraphNodes("graph_nodes.png"), User("user1.png"), FlexibleLeads("flexible_leads.png"), Pads("pads.png"), Lock("lock.png"),
|
Elements("elements1.png"), GraphNodes("graph_nodes.png"), User("user1.png"), FlexibleLeads("flexible_leads.png"), Pads("pads.png"), Lock("lock.png"),
|
||||||
Unlock("lock_open.png");
|
Unlock("lock_open.png"), Earth("earth.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 990 B |
@@ -21,14 +21,18 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
|
import org.diylc.appframework.miscutils.IConfigListener;
|
||||||
import org.diylc.common.EventType;
|
import org.diylc.common.EventType;
|
||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.components.autocreate.SolderPadAutoCreator;
|
import org.diylc.components.autocreate.SolderPadAutoCreator;
|
||||||
import org.diylc.core.Theme;
|
import org.diylc.core.Theme;
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
|
import org.diylc.lang.TranslateUtil;
|
||||||
import org.diylc.swing.ActionFactory;
|
import org.diylc.swing.ActionFactory;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
|
|
||||||
@@ -52,6 +56,7 @@ public class ConfigPlugin implements IPlugIn {
|
|||||||
public static final String COMPONENT_BROWSER = "componentBrowser";
|
public static final String COMPONENT_BROWSER = "componentBrowser";
|
||||||
public static final String SEARCHABLE_TREE = "Searchable Tree";
|
public static final String SEARCHABLE_TREE = "Searchable Tree";
|
||||||
public static final String TABBED_TOOLBAR = "Tabbed Toolbar";
|
public static final String TABBED_TOOLBAR = "Tabbed Toolbar";
|
||||||
|
private static final String LANGUAGE_MENU = "Language";
|
||||||
|
|
||||||
private ISwingUI swingUI;
|
private ISwingUI swingUI;
|
||||||
|
|
||||||
@@ -133,6 +138,21 @@ public class ConfigPlugin implements IPlugIn {
|
|||||||
ActionFactory.getInstance()
|
ActionFactory.getInstance()
|
||||||
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
|
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<String> languages = TranslateUtil.getAvailableLanguages();
|
||||||
|
if (languages != null && languages.size() > 0) {
|
||||||
|
swingUI.injectSubmenu(LANGUAGE_MENU, IconLoader.Earth.getIcon(), CONFIG_MENU);
|
||||||
|
for(String language : languages) {
|
||||||
|
swingUI.injectMenuAction(
|
||||||
|
ActionFactory.getInstance().createToggleAction(language, IPlugInPort.LANGUAGE, LANGUAGE_MENU, IPlugInPort.LANGUAGE_DEFAULT),
|
||||||
|
LANGUAGE_MENU);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Error while setting up language menu", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
File themeDir = new File("themes");
|
File themeDir = new File("themes");
|
||||||
if (themeDir.exists()) {
|
if (themeDir.exists()) {
|
||||||
XStream xStream = new XStream(new DomDriver());
|
XStream xStream = new XStream(new DomDriver());
|
||||||
@@ -157,6 +177,15 @@ public class ConfigPlugin implements IPlugIn {
|
|||||||
COMPONENT_BROWSER_MENU);
|
COMPONENT_BROWSER_MENU);
|
||||||
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(TABBED_TOOLBAR),
|
swingUI.injectMenuAction(ActionFactory.getInstance().createComponentBrowserAction(TABBED_TOOLBAR),
|
||||||
COMPONENT_BROWSER_MENU);
|
COMPONENT_BROWSER_MENU);
|
||||||
|
|
||||||
|
// notify the user that language selection is not immediate
|
||||||
|
ConfigurationManager.getInstance().addConfigListener(IPlugInPort.LANGUAGE, new IConfigListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(String key, Object value) {
|
||||||
|
swingUI.showMessage("Language selection will be applied after the application is restarted.", "Language", ISwingUI.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user