コード例 #1
0
    public static Dictionary <string, string> LoadAllFromResources(EB.Language locale, string[] locFiles)
    {
        var l    = EB.Localizer.GetSparxLanguageCode(locale);
        var dict = new Dictionary <string, string>();
        var file = new EB.LocFile(dict);

        foreach (string name in locFiles)
        {
            file.Read(File.ReadAllText(Path.Combine(Path.GetDirectoryName(LocSourceFolder), l + "/" + name + ".txt")));
        }

        return(dict);
    }
コード例 #2
0
        private static Hashtable LoadStringsInternal(string data)
        {
            // notice: lock order is important
            lock (_strings)
                lock (_status)
                {
                    var file = new LocFile(_strings, _status);
//#if UNITY_EDITOR || UNITY_IOS
                    return(file.Read(data));
//#else
//					return file.ToRead(data);
//#endif
                }
        }
コード例 #3
0
 public static EB.LocFile GetLocDb(string name)
 {
     EB.LocFile file = null;
     if (!_files.TryGetValue(name, out file))
     {
         file = new EB.LocFile();
         try
         {
             file.Read(File.ReadAllText(Path.Combine(LocSourceFolder, name + ".txt")));
         }
         catch
         {
             //Debug.LogError("Failed to load db " + name);
         }
         _files[name] = file;
     }
     return(file);
 }
コード例 #4
0
    public static void PatchTranslationsToBundles(Dictionary <EB.Language, string> transData)
    {
        foreach (var csv in transData)
        {
            //Convert Server Data
            var remote     = new Dictionary <string, string>();
            var remoteFile = new EB.LocFile(remote);
            remoteFile.Read(csv.Value);

            //Get Local Data
            var local = LoadAllFromResources(csv.Key, new string[] { "all" });

            //Patch
            foreach (var entry in remote)
            {
                if (local.ContainsKey(entry.Key))
                {
                    local[entry.Key] = entry.Value;
                }
                else
                {
                    local.Add(entry.Key, entry.Value);
                }
            }

            var localFile = new EB.LocFile(local.OrderBy(entry => entry.Key).ToDictionary(entry => entry.Key, entry => entry.Value));
            var bytes     = EB.Encoding.GetBytes(localFile.Write());

            var code = EB.Localizer.GetSparxLanguageCode(csv.Key);
            var dir  = "Assets/Bundles/Languages";
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            File.WriteAllBytes(Path.Combine(dir, code + ".txt"), bytes);
        }

        AssetDatabase.Refresh();
    }