package extension.locale;

class Locale {

	private static var _getLangCode:Void->String =
		#if android
			openfl.utils.JNI.createStaticMethod("localeExtension/Locale", "getLangCode", "()Ljava/lang/String;");
		#elseif ios
			cpp.Lib.load("openflLocaleExtension","get_lang_code",0);
		#elseif (flash || openfl)
			function():String return flash.system.Capabilities.language;
		#else
			function():String return null;
		#end

	public static function getLangCode():String{
		var res:String=_getLangCode();
		if (res==null) return null;
		return StringTools.replace(res,'_','-');
	}

}
package extension.locale;

class Locale {

	private static var _getLangCode:Void->String =
		#if android
			openfl.utils.JNI.createStaticMethod("localeExtension/Locale", "getLangCode", "()Ljava/lang/String;");
		#elseif ios
			cpp.Lib.load("openflLocaleExtension","get_lang_code",0);
		#elseif (flash || openfl)
			function():String return flash.system.Capabilities.language;
		#else
			function():String return 'en';
		#end

	public static function getLangCode():String{
		return StringTools.replace(_getLangCode(),'_','-');
	}


	public static function getSmartLangCode():String {
		var lang=getLangCode().toLowerCase().substring(0,7);
		if(lang.substring(0,2)=='zh'){
			if(lang=='zh-hans' || lang=='zh-cn' || lang=='zh-sg' || lang=='zh-my' || lang=='zh-rcn' || lang=='zh-rsg' || lang=='zh-rmy'){
				return 'zh-hans';
			}
			return 'zh-hant';
		}
		return lang.substring(0,2);
	}


}
Add getSmartLangCode() function (to provide lang code as flash protocol: two letters unless Chinese)
Add getSmartLangCode() function (to provide lang code as flash protocol: two letters unless Chinese)

thomasuster/openfl-locale,fbricker/extension-locale,SempaiGames/extension-locale,SempaiGames/extension-locale,thomasuster/openfl-locale,fbricker/extension-locale,fbricker/extension-locale,thomasuster/openfl-locale