Quellcode durchsuchen

Implement get_lang and getLocale() to System.js.hx (#981)

Maurice Doison vor 4 Jahren
Ursprung
Commit
5e077992c1
2 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen
  1. 4 0
      hxd/System.hx
  2. 5 1
      hxd/System.js.hx

+ 4 - 0
hxd/System.hx

@@ -85,6 +85,10 @@ class System {
 		return null;
 	}
 
+	public static function getLocale() : String {
+		return "en_EN";
+	}
+
 	// getters
 
 	static function get_width() : Int return 0;

+ 5 - 1
hxd/System.js.hx

@@ -148,11 +148,15 @@ class System {
 		return false;
 	}
 
+	public static function getLocale() : String {
+		return js.Browser.navigator.language + "_" + js.Browser.navigator.language.toUpperCase();
+	}
+
 	// getters
 
 	static function get_width() : Int return Math.round(js.Browser.document.body.clientWidth * js.Browser.window.devicePixelRatio);
 	static function get_height() : Int return Math.round(js.Browser.document.body.clientHeight  * js.Browser.window.devicePixelRatio);
-	static function get_lang() : String return "en";
+	static function get_lang() : String return js.Browser.navigator.language;
 	static function get_platform() : Platform {
 		var ua = js.Browser.navigator.userAgent.toLowerCase();
 		if( ua.indexOf("android")>=0 )