Exemplo n.º 1
0
    static void ImportLocaFile(string pPath)
    {
        UGBLocaParser parser = new UGBLocaParser();

        parser.Parse(pPath);


        // now that loca is parsed, generating loca files.
        var languages = parser.GetLanguages();

        for (int i = 0; i < languages.Count; i++)
        {
            // Load Loca for language
            LocaData ld = LocaData.Load(languages[i]);

            // Add all parsed keys to the loca file
            foreach (UGBLocaParser.CLocaEntry e in parser.GetEntries())
            {
                if (i > 0 && i < e.mTranslations.Length && e.mTranslations[i] != null)
                {
                    ld.AddText(e.mKey, e.mTranslations[i]);
                }
            }

            // Save Loca file
            ld.Save();
        }

        AssetDatabase.Refresh();
    }
Exemplo n.º 2
0
        static void OnPostprocessAllAssets(
            string[] pImportedAssets,
            string[] pDeletedAssets,
            string[] pMovedAssets,
            string[] pMovedFromAssetsPaths)
        {
            foreach (string imported in pImportedAssets)
            {
                if (!imported.Contains("loca"))
                {
                    continue;
                }

                UGBLocaParser parser = null;
                if (imported.EndsWith(".xml"))
                {
                    parser = new UGBXmlLocaParser();
                    parser.Parse(imported);
                }
                else if (imported.EndsWith(".csv"))
                {
                    parser = new UGBCsvLocaParser();
                    parser.Parse(imported);
                }
                else
                {
                    continue;
                }

                // now that loca is parsed, generating loca files.
                var languages = parser.GetLanguages();

                for (int i = 0; i < languages.Count; i++)
                {
                    // Load Loca for language
                    LocaData ld = LocaData.Load(languages[i]);

                    // Add all parsed keys to the loca file
                    foreach (CLocaEntry e in parser.GetEntries())
                    {
                        if (i < e.mTranslations.Length)
                        {
                            ld.AddText(e.mKey, e.mTranslations[i]);
                        }
                    }

                    // Save Loca file
                    ld.Save();
                }

                AssetDatabase.Refresh();
            }
        }