2
0
Эх сурвалжийг харах

Added an option to allow the loading of regional specific languages (#979)

Maurice Doison 4 жил өмнө
parent
commit
8775d86b3d
1 өөрчлөгдсөн 10 нэмэгдсэн , 3 устгасан
  1. 10 3
      hxd/System.hl.hx

+ 10 - 3
hxd/System.hl.hx

@@ -47,6 +47,9 @@ class System {
 	static var currentCustomCursor : hxd.Cursor.CustomCursor;
 	static var cursorVisible = true;
 
+	public static var allowLCID : Bool = false;
+	static var lcidMapping = [ "zh-TW" => "zh-TW", "zh-HK" => "zh-TW", "zh-MO" => "zh-TW" ];
+
 	public static function getCurrentLoop() : Void -> Void {
 		return loopFunc;
 	}
@@ -355,8 +358,11 @@ class System {
 	static var _lang : String;
 	static function get_lang() : String {
 		if( _lang == null ) {
-			var str = getLocale();
-			_lang = str.split("-").shift();
+			var loc = getLocale();
+			if( allowLCID && lcidMapping.exists(loc) )
+				_lang = lcidMapping[loc];
+			else
+				_lang = loc.split("-")[0];
 		}
 		return _lang;
 	}
@@ -369,7 +375,8 @@ class System {
 		if( _loc == null ) {
 			var str = @:privateAccess Sys.makePath(sys_locale());
 			if( str == null ) str = "en";
-			_loc = ~/[.@_]/g.split(str)[0];
+			_loc = ~/[.@]/g.split(str)[0];
+			_loc = ~/_/g.replace(_loc, "-");
 		}
 		return _loc;
 	}