From 48d8d3a411e0d73eedef5bdb0c7a4d81284b6207 Mon Sep 17 00:00:00 2001 From: Andy Chabalier Date: Thu, 27 Sep 2018 17:28:53 +0200 Subject: [PATCH] Adding internationalizing classes, with french, english, spanish and default local. Adding Icon --- .../util/languages/StringSources.java | 39 ++++++++++++++++++ .../util/languages/stringsources.properties | 9 ++++ .../languages/stringsources_en_GB.properties | 9 ++++ .../languages/stringsources_es_ES.properties | 9 ++++ .../languages/stringsources_fr_FR.properties | 9 ++++ .../fr/uha/gabalier/util/ressources/logo.jpg | Bin 0 -> 4107 bytes .../java/fr/uha/gabalier/view/Preview.java | 17 ++++---- 7 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 src/main/java/fr/uha/gabalier/util/languages/StringSources.java create mode 100644 src/main/java/fr/uha/gabalier/util/languages/stringsources.properties create mode 100644 src/main/java/fr/uha/gabalier/util/languages/stringsources_en_GB.properties create mode 100644 src/main/java/fr/uha/gabalier/util/languages/stringsources_es_ES.properties create mode 100644 src/main/java/fr/uha/gabalier/util/languages/stringsources_fr_FR.properties create mode 100644 src/main/java/fr/uha/gabalier/util/ressources/logo.jpg diff --git a/src/main/java/fr/uha/gabalier/util/languages/StringSources.java b/src/main/java/fr/uha/gabalier/util/languages/StringSources.java new file mode 100644 index 0000000..ef484bd --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/StringSources.java @@ -0,0 +1,39 @@ +package fr.uha.gabalier.util.languages; + +import java.beans.Beans; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class StringSources { + //////////////////////////////////////////////////////////////////////////// + // + // Constructor + // + //////////////////////////////////////////////////////////////////////////// + private StringSources() { + // do not instantiate + } + //////////////////////////////////////////////////////////////////////////// + // + // Bundle access + // + //////////////////////////////////////////////////////////////////////////// + private static final String BUNDLE_NAME = "fr.uha.gabalier.util.languages.stringsources"; //$NON-NLS-1$ + private static final ResourceBundle RESOURCE_BUNDLE = loadBundle(); + private static ResourceBundle loadBundle() { + return ResourceBundle.getBundle(BUNDLE_NAME); + } + //////////////////////////////////////////////////////////////////////////// + // + // Strings access + // + //////////////////////////////////////////////////////////////////////////// + public static String getString(String key) { + try { + ResourceBundle bundle = Beans.isDesignTime() ? loadBundle() : RESOURCE_BUNDLE; + return bundle.getString(key); + } catch (MissingResourceException e) { + return "!" + key + "!"; + } + } +} diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources.properties new file mode 100644 index 0000000..d55a42e --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:39 CEST 2018 +Preview.cancelItem.text=Cancel +Preview.exitItem.text=Exit +Preview.fileMenu.text=File +Preview.loadItem.text=Load +Preview.other.text=status \: +Preview.statusText.text=0000 images loaded +Preview.this.title=Image Loader diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources_en_GB.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources_en_GB.properties new file mode 100644 index 0000000..d55a42e --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources_en_GB.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:39 CEST 2018 +Preview.cancelItem.text=Cancel +Preview.exitItem.text=Exit +Preview.fileMenu.text=File +Preview.loadItem.text=Load +Preview.other.text=status \: +Preview.statusText.text=0000 images loaded +Preview.this.title=Image Loader diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources_es_ES.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources_es_ES.properties new file mode 100644 index 0000000..81c0e54 --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources_es_ES.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:40 CEST 2018 +Preview.cancelItem.text=Cancelar +Preview.exitItem.text=Salir +Preview.fileMenu.text=Archivo +Preview.loadItem.text=Carga +Preview.other.text=Estatus \: +Preview.statusText.text=0000 im\u00E1genes cargadas +Preview.this.title=Cargador de im\u00E1genes diff --git a/src/main/java/fr/uha/gabalier/util/languages/stringsources_fr_FR.properties b/src/main/java/fr/uha/gabalier/util/languages/stringsources_fr_FR.properties new file mode 100644 index 0000000..cd2d24c --- /dev/null +++ b/src/main/java/fr/uha/gabalier/util/languages/stringsources_fr_FR.properties @@ -0,0 +1,9 @@ +#Eclipse messages class +#Thu Sep 27 17:27:39 CEST 2018 +Preview.cancelItem.text=Annuler +Preview.exitItem.text=Quitter +Preview.fileMenu.text=Fichier +Preview.loadItem.text=Charger +Preview.other.text=Status \: +Preview.statusText.text=0000 images charg\u00E9es +Preview.this.title=Visionneuse d'image diff --git a/src/main/java/fr/uha/gabalier/util/ressources/logo.jpg b/src/main/java/fr/uha/gabalier/util/ressources/logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a6f532929cde309db159cbfd233ce933adb95340 GIT binary patch literal 4107 zcmbW3c|6qLzsEmghCvu(Cyc#G*>_p9FJ;S8%8+bLmaG%QSh9X)QeQ+d*+P=ClaM7! zUwcT|hO%WDh7n`tr|v?g((0! z)>+V50HCh}pKN^tLjyy61B1j=gc$&U0bmejU<6oHHI)^W6}2=q zgc*RBMAtfOyB`k^%{k;h2I26hRYG!U>>2S%>$=T)d70(-9-afv5H$y_h!Xq$uA`|W=CMBn&ragH0 zXI6I3qujir;*!#5W#tvmYijH28ycIMTROYCd*1iJaJ+1`;VpN zl~vOA4taNvvj6MgHx~#1|AX~!vj4#aKjvaME(-+un+wDcacp2Xgi&0HiObLq>T#P} zLOG6^=X_@2>vt@YD)w8v*Mo;y`J`0mrAfch{wDk1fyMv7$o>uXUtCiF8yIw4JTM&4 z2M#6DkS{Eo9Q`lSdaYk)(*gU|#@f2X2rHd!<^{u5m#s5#`}3rzF2adWuWag3qjR(U zt-8r4EYiIvC+Psheb*>JM1W|fTc}3ePuGEZ> zqxiN9-}4AY4R1~Ehyh6WjF;)6yh93VVpRHo0b>Au)p>^;Gr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U5Q{u|4<(dHB|>|9-pD#M)^fp1DtLZkCe{ zcnt!WhxR!RBLNDnYPVH#9-I-w2Usj-o`gMIE`i;wmnZ6RX#x*|p!Vo>*ktj1M)iEY zI^}%}Rl!HSn!&^qEkQJi6?tzaa;f<}^jh($s?c_JoVN{tv2jRtYJafP9q~#L6EnkU ac#^}2`A?7IC)t-!8kGSp<+?ve|MD-d4~516 literal 0 HcmV?d00001 diff --git a/src/main/java/fr/uha/gabalier/view/Preview.java b/src/main/java/fr/uha/gabalier/view/Preview.java index ad9dc90..13ecded 100644 --- a/src/main/java/fr/uha/gabalier/view/Preview.java +++ b/src/main/java/fr/uha/gabalier/view/Preview.java @@ -9,6 +9,7 @@ import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; +import fr.uha.gabalier.util.languages.StringSources; public class Preview extends JFrame { @@ -33,6 +34,8 @@ public class Preview extends JFrame { private final JTextField statusText; public Preview() throws HeadlessException { + setIconImage(Toolkit.getDefaultToolkit().getImage(Preview.class.getResource("/fr/uha/gabalier/util/ressources/logo.jpg"))); + setTitle(StringSources.getString("Preview.this.title")); //$NON-NLS-1$ model = new ArrayList<>(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -40,21 +43,21 @@ public class Preview extends JFrame { // UI elements JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); - JMenu fileMenu = new JMenu("File"); + JMenu fileMenu = new JMenu(StringSources.getString("Preview.fileMenu.text")); //$NON-NLS-1$ menuBar.add(fileMenu); - loadItem = new JMenuItem("Load"); + loadItem = new JMenuItem(StringSources.getString("Preview.loadItem.text")); //$NON-NLS-1$ fileMenu.add(loadItem); loadItem.addActionListener(actionEvent -> doLoad()); - cancelItem = new JMenuItem("Cancel"); + cancelItem = new JMenuItem(StringSources.getString("Preview.cancelItem.text")); //$NON-NLS-1$ fileMenu.add(cancelItem); cancelItem.addActionListener(actionEvent -> doCancel()); - final JMenuItem exitItem = new JMenuItem("Exit"); + final JMenuItem exitItem = new JMenuItem(StringSources.getString("Preview.exitItem.text")); //$NON-NLS-1$ exitItem.addActionListener(actionEvent -> doExit()); exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK)); fileMenu.add(exitItem); - setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); + getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); imageView = new ImageView(model); final ImageController controller = new ImageController(model); @@ -73,8 +76,8 @@ public class Preview extends JFrame { final JPanel statusPanel = new JPanel(); getContentPane().add(statusPanel); - statusText = new JTextField("0000 images loaded"); - statusPanel.add(new JLabel("status :")); + statusText = new JTextField(StringSources.getString("Preview.statusText.text")); //$NON-NLS-1$ + statusPanel.add(new JLabel(StringSources.getString("Preview.other.text"))); //$NON-NLS-1$ statusPanel.add(statusText); pack();