Merge Dev
This commit is contained in:
+1
-20
@@ -42,7 +42,7 @@ class App {
|
||||
// The locale should be specified in ISO 639-1 format: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
||||
// "system" is a special case that will use the system locale
|
||||
public static var locale = "system";
|
||||
static var translations: Map<String, String> = [];
|
||||
public static var translations: Map<String, String> = [];
|
||||
public static var isDragging = false;
|
||||
public static var isResizing = false;
|
||||
public static var dragMaterial: MaterialSlot = null;
|
||||
@@ -231,25 +231,6 @@ class App {
|
||||
else System.stop();
|
||||
}
|
||||
|
||||
// Localizes a string with the given placeholders replaced (format is `{placeholderName}`).
|
||||
// If the string isn't available in the translation, this method will return the source English string.
|
||||
public static function tr(id: String, ?vars: Map<String, Dynamic>): String {
|
||||
var translation = id;
|
||||
|
||||
// English is the source language
|
||||
if (locale != "en" && translations != null && translations.exists(id)) {
|
||||
translation = translations[id];
|
||||
}
|
||||
|
||||
if (vars != null) {
|
||||
for (key => value in vars) {
|
||||
translation = translation.replace('{$key}', Std.string(value));
|
||||
}
|
||||
}
|
||||
|
||||
return translation;
|
||||
}
|
||||
|
||||
public static function w(): Int {
|
||||
// Draw material preview
|
||||
if (UISidebar.inst != null && UISidebar.inst.materialPreview) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package arm;
|
||||
|
||||
class Locale {
|
||||
|
||||
// Localize a string with the given placeholders replaced (format is `{placeholderName}`).
|
||||
// TODO: Implement localization support.
|
||||
public static function tr(id: String, ?vars: Map<String, Dynamic>): String {
|
||||
if (vars != null) {
|
||||
for (key => value in vars) {
|
||||
id = id.replace('{$key}', Std.string(value));
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package arm;
|
||||
|
||||
class Translator {
|
||||
|
||||
// Localizes a string with the given placeholders replaced (format is `{placeholderName}`).
|
||||
// If the string isn't available in the translation, this method will return the source English string.
|
||||
public static function tr(id: String, ?vars: Map<String, Dynamic>): String {
|
||||
var translation = id;
|
||||
|
||||
// English is the source language
|
||||
if (App.locale != "en" && App.translations != null && App.translations.exists(id)) {
|
||||
translation = App.translations[id];
|
||||
}
|
||||
|
||||
if (vars != null) {
|
||||
for (key => value in vars) {
|
||||
translation = translation.replace('{$key}', Std.string(value));
|
||||
}
|
||||
}
|
||||
|
||||
return translation;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class BoxPreferences {
|
||||
Config.raw.locale = localeCode;
|
||||
Config.save();
|
||||
App.loadTranslations(localeCode);
|
||||
UITrait.inst.tagUIRedraw();
|
||||
UISidebar.inst.tagUIRedraw();
|
||||
}
|
||||
|
||||
var hscale = Id.handle({value: Config.raw.window_scale});
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
#if (!macro)
|
||||
|
||||
import arm.Locale.tr;
|
||||
import arm.Translator.tr;
|
||||
using StringTools;
|
||||
|
||||
#end
|
||||
|
||||
Reference in New Issue
Block a user