Beispiel #1
0
        private static void LoadCSVLocalization(Object asset)
        {
            TextAsset textAsset = asset.Cast <TextAsset>();

            if (textAsset is null)
            {
                Logger.LogWarning("Asset called '{0}' is not a TextAsset as expected.", asset.name);
                return;
            }

            //Implementation.Log("Processing asset '{0}' as csv localization.", asset.name);

            ByteReader byteReader = new ByteReader(textAsset);

            string[] languages = ModAssetBundleManager.Trim(byteReader.ReadCSV().ToArray());

            while (true)
            {
                string[] values = byteReader.ReadCSV()?.ToArray();
                if (values is null || languages is null || values.Length == 0 || languages.Length == 0)
                {
                    break;
                }

                string locID = values[0];
                Dictionary <string, string> locDict = new Dictionary <string, string>();

                int maxIndex = System.Math.Min(values.Length, languages.Length);
                for (int j = 1; j < maxIndex; j++)
                {
                    if (!string.IsNullOrEmpty(values[j]) && !string.IsNullOrEmpty(languages[j]))
                    {
                        locDict.Add(languages[j], values[j]);
                    }
                }

                LoadLocalization(locID, locDict, USE_ENGLISH_AS_DEFAULT);
            }
        }