Merge pull request #2844 from federicobond/fix-osx-localization

Fix localization in OS X
This commit is contained in:
Ben Fry
2014-09-10 09:48:31 -04:00
5 changed files with 46 additions and 2 deletions
+2
View File
@@ -87,6 +87,7 @@ public class Language {
static private String[] listSupported() {
// List of languages in alphabetical order. (Add yours here.)
// Also remember to add it to the corresponding build/build.xml rule.
final String[] SUPPORTED = {
"de", // German, Deutsch
"en", // English
@@ -147,6 +148,7 @@ public class Language {
} catch (Exception e) {
e.printStackTrace();
}
Base.getPlatform().saveLanguage(language);
}
+2 -1
View File
@@ -74,6 +74,7 @@ public class Platform {
}
}
public void saveLanguage(String languageCode) {}
public void init(Base base) {
this.base = base;
@@ -216,4 +217,4 @@ public class Platform {
null);
}
*/
}
}
@@ -24,6 +24,7 @@ package processing.app.platform;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import com.apple.eio.FileManager;
@@ -47,6 +48,18 @@ public class MacPlatform extends Platform {
}
*/
public void saveLanguage(String language) {
String[] cmdarray = new String[]{
"defaults", "write",
System.getProperty("user.home") + "/Library/Preferences/org.processing.app",
"AppleLanguages", "-array", language
};
try {
Runtime.getRuntime().exec(cmdarray);
} catch (IOException e) {
Base.log("Error saving platform language: " + e.getMessage());
}
}
public void init(Base base) {
super.init(base);
@@ -205,4 +218,4 @@ public class MacPlatform extends Platform {
protected String getDocumentsFolder() throws FileNotFoundException {
return FileManager.findFolder(kUserDomain, kDocumentsFolderType);
}
}
}