Set() public static method

public static Set ( string key, string value ) : void
key string
value string
return void
Ejemplo n.º 1
0
    static int Set(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(string)))
        {
            string arg0 = LuaScriptMgr.GetString(L, 1);
            string arg1 = LuaScriptMgr.GetString(L, 2);
            Localization.Set(arg0, arg1);
            return(0);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(Dictionary <string, string>)))
        {
            string arg0 = LuaScriptMgr.GetString(L, 1);
            Dictionary <string, string> arg1 = (Dictionary <string, string>)LuaScriptMgr.GetLuaObject(L, 2);
            Localization.Set(arg0, arg1);
            return(0);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(byte[])))
        {
            string arg0  = LuaScriptMgr.GetString(L, 1);
            byte[] objs1 = LuaScriptMgr.GetArrayNumber <byte>(L, 2);
            Localization.Set(arg0, objs1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: Localization.Set");
        }

        return(0);
    }
Ejemplo n.º 2
0
    static int Set(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        string arg0 = LuaScriptMgr.GetLuaString(L, 1);
        Dictionary <string, string> arg1 = (Dictionary <string, string>)LuaScriptMgr.GetNetObject(L, 2, typeof(Dictionary <string, string>));

        Localization.Set(arg0, arg1);
        return(0);
    }
Ejemplo n.º 3
0
    private static int Set(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        string luaString = LuaScriptMgr.GetLuaString(L, 1);
        Dictionary <string, string> dictionary = (Dictionary <string, string>)LuaScriptMgr.GetNetObject(L, 2, typeof(Dictionary <string, string>));

        Localization.Set(luaString, dictionary);
        return(0);
    }
Ejemplo n.º 4
0
 static public int Set_s(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 1, typeof(string), typeof(string)))
         {
             System.String a1;
             checkType(l, 1, out a1);
             System.String a2;
             checkType(l, 2, out a2);
             Localization.Set(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 1, typeof(string), typeof(Dictionary <System.String, System.String>)))
         {
             System.String a1;
             checkType(l, 1, out a1);
             System.Collections.Generic.Dictionary <System.String, System.String> a2;
             checkType(l, 2, out a2);
             Localization.Set(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 1, typeof(string), typeof(System.Byte[])))
         {
             System.String a1;
             checkType(l, 1, out a1);
             System.Byte[] a2;
             checkArray(l, 2, out a2);
             Localization.Set(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             System.String a1;
             checkType(l, 1, out a1);
             System.String a2;
             checkType(l, 2, out a2);
             System.String a3;
             checkType(l, 3, out a3);
             Localization.Set(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 5
0
    //载入多语言文本后,调用这个进行初始化
    public static void Init()
    {
        if (loadedBinaryTextAsset == null)
        {
            Debug.LogError("localized text is not loaded");
            return;
        }

        isInited = true;
        Localization.Set(loadedBinaryTextAsset.name, loadedBinaryTextAsset.text);
        loadedBinaryTextAsset = null;
    }
Ejemplo n.º 6
0
    protected override void OnInitialize()
    {
        m_LanguageCN.onClick.AddListener(() => { Localization.Set("CN"); });
        m_LanguageEN.onClick.AddListener(() => { Localization.Set("EN"); });
        m_LanguageJP.onClick.AddListener(() => { Localization.Set("JP"); });
        m_LanguageKR.onClick.AddListener(() => { Localization.Set("KR"); });

        Localization.languageChange += () => {
            ConfigLoader.ReloadLocalization();
            ConfigLoader.compelted += () => { DisplayLabel(); };
        };
    }
Ejemplo n.º 7
0
 private static bool LoadDictionary(string value, bool merge = false)
 {
     byte[] array = null;
     if (!Localization.localizationHasBeenSet)
     {
         if (Localization.loadFunction == null)
         {
             TextAsset textAsset = Resources.Load <TextAsset>("Localization");
             if (textAsset != null)
             {
                 array = textAsset.bytes;
             }
         }
         else
         {
             array = Localization.loadFunction("Localization");
         }
         Localization.localizationHasBeenSet = true;
     }
     if (Localization.LoadCSV(array, merge))
     {
         return(true);
     }
     if (string.IsNullOrEmpty(value))
     {
         value = Localization.mLanguage;
     }
     if (string.IsNullOrEmpty(value))
     {
         return(false);
     }
     if (Localization.loadFunction == null)
     {
         TextAsset textAsset2 = Resources.Load <TextAsset>(value);
         if (textAsset2 != null)
         {
             array = textAsset2.bytes;
         }
     }
     else
     {
         array = Localization.loadFunction(value);
     }
     if (array != null)
     {
         Localization.Set(value, array);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 8
0
        static int _m_Set_xlua_st_(RealStatePtr L)
        {
            try {
                {
                    string _language = LuaAPI.lua_tostring(L, 1);

                    Localization.Set(_language);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Ejemplo n.º 9
0
    static int Set(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <string>(L, 2))
            {
                string arg0 = ToLua.CheckString(L, 1);
                string arg1 = ToLua.ToString(L, 2);
                Localization.Set(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <System.Collections.Generic.Dictionary <string, string> >(L, 2))
            {
                string arg0 = ToLua.CheckString(L, 1);
                System.Collections.Generic.Dictionary <string, string> arg1 = (System.Collections.Generic.Dictionary <string, string>)ToLua.ToObject(L, 2);
                Localization.Set(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <byte[]>(L, 2))
            {
                string arg0 = ToLua.CheckString(L, 1);
                byte[] arg1 = ToLua.CheckByteBuffer(L, 2);
                Localization.Set(arg0, arg1);
                return(0);
            }
            else if (count == 3)
            {
                string arg0 = ToLua.CheckString(L, 1);
                string arg1 = ToLua.CheckString(L, 2);
                string arg2 = ToLua.CheckString(L, 3);
                Localization.Set(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Localization.Set"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 10
0
    // Use this for initialization
    void Awake()
    {
        Debug.Log("1111111111");

        //再次加载语言
        string languageFile  = "Assets/Resources/English.txt";
        string languageFile2 = "Assets/Resources/Chinese.txt";


        byte[] buff = File.ReadAllBytes(languageFile);
        Localization.Set("English", buff);

        byte[] buff2 = File.ReadAllBytes(languageFile2);
        Localization.Set("Chinese", buff2);

        Localization.language = "English";
        Debug.Log(Localization.language);
    }
Ejemplo n.º 11
0
        private void Start()
        {
#if !UNITY_METRO
            // Check for overridden localization data.
            var      localizationFilePath = Application.persistentDataPath + "/Localization.txt";
            FileInfo localizationFile     = new FileInfo(localizationFilePath);

            if (localizationFile.Exists)
            {
                Debug.Log("Found localization file at " + localizationFilePath);

                using (var fileStream = localizationFile.OpenRead())
                {
                    using (var binaryReader = new BinaryReader(fileStream))
                    {
                        var bytes            = binaryReader.ReadBytes((int)localizationFile.Length);
                        var nguiByteReader   = new ByteReader(bytes);
                        var localizationData = nguiByteReader.ReadDictionary();
                        Localization.Set("TestLanguage", localizationData);
                        return;
                    }
                }
            }
#endif

            // Get current system language.
            SystemLanguage systemLanguage = Application.systemLanguage;
            Debug.Log(string.Format("System Language: {0}", systemLanguage));

            // Check if available, otherwise fallback to English.
            TextAsset textAsset = Resources.Load(systemLanguage.ToString(), typeof(TextAsset)) as TextAsset;
            if (textAsset == null)
            {
                systemLanguage = SystemLanguage.English;
                Debug.Log(string.Format("Using fallback language: {0}", systemLanguage));
            }

            Localization.language = systemLanguage.ToString();
        }
Ejemplo n.º 12
0
    public static void Set(string languageName, byte[] bytes)
    {
        ByteReader byteReader = new ByteReader(bytes);

        Localization.Set(languageName, byteReader.ReadDictionary());
    }
Ejemplo n.º 13
0
    public static void Load(TextAsset asset)
    {
        ByteReader byteReader = new ByteReader(asset);

        Localization.Set(asset.name, byteReader.ReadDictionary());
    }
Ejemplo n.º 14
0
 public unsafe static long $Invoke22(long instance, long *args)
 {
     Localization.Set(Marshal.PtrToStringUni(*(IntPtr *)args), Marshal.PtrToStringUni(*(IntPtr *)(args + 1)));
     return(-1L);
 }
Ejemplo n.º 15
0
 public unsafe static long $Invoke21(long instance, long *args)
 {
     Localization.Set(Marshal.PtrToStringUni(*(IntPtr *)args), (Dictionary <string, string>)GCHandledObjects.GCHandleToObject(args[1]));
     return(-1L);
 }
Ejemplo n.º 16
0
 public unsafe static long $Invoke20(long instance, long *args)
 {
     Localization.Set(Marshal.PtrToStringUni(*(IntPtr *)args), (byte[])GCHandledObjects.GCHandleToPinnedArrayObject(args[1]));
     return(-1L);
 }