summaryrefslogtreecommitdiffstats
path: root/logo
diff options
context:
space:
mode:
Diffstat (limited to 'logo')
-rw-r--r--logo/src/xlogo/Logo.java10
-rw-r--r--logo/src/xlogo/MenuListener.java2
-rw-r--r--logo/src/xlogo/gui/Traduc.java3
-rw-r--r--logo/src/xlogo/gui/welcome/WelcomeScreen.java2
-rw-r--r--logo/src/xlogo/kernel/LaunchPrimitive.java3
-rw-r--r--logo/src/xlogo/kernel/Primitive.java3
-rw-r--r--logo/src/xlogo/storage/workspace/Language.java24
-rw-r--r--logo/src/xlogo/storage/workspace/WorkspaceConfig.java2
-rw-r--r--logo/src/xlogo/utils/Utils.java4
9 files changed, 39 insertions, 14 deletions
diff --git a/logo/src/xlogo/Logo.java b/logo/src/xlogo/Logo.java
index 580c28b..41a399c 100644
--- a/logo/src/xlogo/Logo.java
+++ b/logo/src/xlogo/Logo.java
@@ -112,14 +112,16 @@ public class Logo {
/**Builds Application with the valid Config*/
public Logo() {
WorkspaceConfig wc = WSManager.getWorkspaceConfig();
- Language lang = Language.ENGLISH;
+ // Language for User Interface
+ Language lang = Language.getDefault();
if (wc != null){
- lang = WSManager.getInstance().getWorkspaceConfigInstance().getLanguage();
+ lang = AppSettings.getInstance().getLanguage();
}
generateLanguage(lang);
+ // Logo Programming Language
LogoLanguage logo = LogoLanguage.ENGLISH;
if (wc != null){
- lang = WSManager.getInstance().getWorkspaceConfigInstance().getLanguage();
+ logo = WSManager.getInstance().getWorkspaceConfigInstance().getLogoLanguage();
}
generateLogoLanguage(logo);
@@ -157,7 +159,7 @@ public class Logo {
WorkspaceConfig wc = WSManager.getInstance().getWorkspaceConfigInstance();
welcomeScreen.closeFrame();
- generateLanguage(wc.getLanguage());
+ generateLanguage(AppSettings.getInstance().getLanguage());
generateLogoLanguage(wc.getLogoLanguage());
// Initialize frame
diff --git a/logo/src/xlogo/MenuListener.java b/logo/src/xlogo/MenuListener.java
index aae8477..e245ef3 100644
--- a/logo/src/xlogo/MenuListener.java
+++ b/logo/src/xlogo/MenuListener.java
@@ -111,7 +111,7 @@ public class MenuListener extends JDialog implements ActionListener {
* task corresponding to the incoming event.
*/
public void actionPerformed(ActionEvent e) {
- Language lang = WSManager.getWorkspaceConfig().getLanguage();
+ Language lang = AppSettings.getInstance().getLanguage();
String cmd = e.getActionCommand();
if (MenuListener.EDIT_COPY.equals(cmd)) { // Copier
diff --git a/logo/src/xlogo/gui/Traduc.java b/logo/src/xlogo/gui/Traduc.java
index 7fa1b3c..7e8ca97 100644
--- a/logo/src/xlogo/gui/Traduc.java
+++ b/logo/src/xlogo/gui/Traduc.java
@@ -41,6 +41,7 @@ import xlogo.storage.WSManager;
import xlogo.storage.workspace.Language;
import xlogo.storage.workspace.WorkspaceConfig;
import xlogo.utils.Utils;
+import xlogo.AppSettings;
import xlogo.Logo;
/**
* Title : XLogo
@@ -87,7 +88,7 @@ public class Traduc extends JFrame implements ActionListener {
public Traduc(){
WorkspaceConfig wc = WSManager.getWorkspaceConfig();
Font font = wc.getFont();
- Language lang = wc.getLanguage();
+ Language lang = AppSettings.getInstance().getLanguage();
setTitle(Logo.messages.getString("menu.tools.translate"));
setIconImage(Toolkit.getDefaultToolkit().createImage(Utils.class.getResource("icone.png")));
diff --git a/logo/src/xlogo/gui/welcome/WelcomeScreen.java b/logo/src/xlogo/gui/welcome/WelcomeScreen.java
index b9eb304..79fade7 100644
--- a/logo/src/xlogo/gui/welcome/WelcomeScreen.java
+++ b/logo/src/xlogo/gui/welcome/WelcomeScreen.java
@@ -474,7 +474,7 @@ public class WelcomeScreen extends X4SFrame {
WebPage editorPane = new WebPage();
editorPane.setEditable(false);
- String langCode = WSManager.getWorkspaceConfig().getLanguage().getLanguageCode();
+ String langCode = AppSettings.getInstance().getLanguage().getLanguageCode();
String path = "gpl/gpl-" + langCode + ".html";
diff --git a/logo/src/xlogo/kernel/LaunchPrimitive.java b/logo/src/xlogo/kernel/LaunchPrimitive.java
index aaa765e..d52bac8 100644
--- a/logo/src/xlogo/kernel/LaunchPrimitive.java
+++ b/logo/src/xlogo/kernel/LaunchPrimitive.java
@@ -69,6 +69,7 @@ import xlogo.gui.Lis;
import xlogo.gui.MyTextAreaDialog;
import xlogo.kernel.DrawPanel;
import xlogo.gui.HistoryPanel;
+import xlogo.AppSettings;
import xlogo.Application;
import xlogo.Logo;
import xlogo.kernel.network.*;
@@ -200,7 +201,7 @@ public class LaunchPrimitive
}
else
{
- Language lang = WSManager.getInstance().getWorkspaceConfigInstance().getLanguage();
+ Language lang = AppSettings.getInstance().getLanguage();
switch (id)
{
diff --git a/logo/src/xlogo/kernel/Primitive.java b/logo/src/xlogo/kernel/Primitive.java
index b6f2aa5..5a9cb14 100644
--- a/logo/src/xlogo/kernel/Primitive.java
+++ b/logo/src/xlogo/kernel/Primitive.java
@@ -45,7 +45,6 @@ import java.math.BigDecimal;
import xlogo.kernel.LoopProperties;
import xlogo.messages.async.history.HistoryMessenger;
-import xlogo.storage.WSManager;
import xlogo.storage.workspace.LogoLanguage;
import xlogo.utils.Utils;
import xlogo.AppSettings;
@@ -102,7 +101,7 @@ public class Primitive
protected String getAllPrimitives()
{
Vector<String> list = new Vector<String>();
- Locale locale = WSManager.getInstance().getWorkspaceConfigInstance().getLanguage().getLocale();
+ Locale locale = AppSettings.getInstance().getLanguage().getLocale();
ResourceBundle prim = ResourceBundle.getBundle("primitives", locale);
try
{
diff --git a/logo/src/xlogo/storage/workspace/Language.java b/logo/src/xlogo/storage/workspace/Language.java
index d1c3469..98baec2 100644
--- a/logo/src/xlogo/storage/workspace/Language.java
+++ b/logo/src/xlogo/storage/workspace/Language.java
@@ -109,5 +109,27 @@ public enum Language {
{
return countryCode;
}
-
+
+ /**
+ * Try to get best match for locale or english otherwise
+ * @param locale
+ * @return
+ */
+ public static Language forLocale(Locale locale){
+ Language result = Language.ENGLISH;
+ for (Language lang : Language.values()){
+ Locale l = lang.getLocale();
+ if(l.equals(locale)){
+ return lang;
+ }
+ if (l.getLanguage().equals(locale.getLanguage())){
+ result = lang;
+ }
+ }
+ return result;
+ }
+
+ public static Language getDefault(){
+ return forLocale(Locale.getDefault());
+ }
}
diff --git a/logo/src/xlogo/storage/workspace/WorkspaceConfig.java b/logo/src/xlogo/storage/workspace/WorkspaceConfig.java
index 2f2a8db..d6a17f2 100644
--- a/logo/src/xlogo/storage/workspace/WorkspaceConfig.java
+++ b/logo/src/xlogo/storage/workspace/WorkspaceConfig.java
@@ -290,7 +290,7 @@ public class WorkspaceConfig implements Serializable, Observable<WorkspaceConfig
public Language getLanguage() {
if (language == null)
- return Language.ENGLISH;
+ return Language.getDefault();
return language;
}
diff --git a/logo/src/xlogo/utils/Utils.java b/logo/src/xlogo/utils/Utils.java
index 991cc8e..9a56cfd 100644
--- a/logo/src/xlogo/utils/Utils.java
+++ b/logo/src/xlogo/utils/Utils.java
@@ -62,7 +62,7 @@ import org.json.JSONObject;
import xlogo.kernel.MyCalculator;
import xlogo.kernel.Affichage;
import xlogo.storage.WSManager;
-import xlogo.storage.workspace.Language;
+import xlogo.storage.workspace.LogoLanguage;
import xlogo.Logo;
public class Utils {
@@ -622,7 +622,7 @@ public class Utils {
}
public static String primitiveName(String generic) {
- Language lang = WSManager.getInstance().getWorkspaceConfigInstance().getLanguage();
+ LogoLanguage lang = WSManager.getInstance().getWorkspaceConfigInstance().getLogoLanguage();
Locale locale = lang.getLocale();
ResourceBundle prim = ResourceBundle.getBundle("primitives", locale);
String st = prim.getString(generic);