Exemplo n.º 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);
    }
Exemplo n.º 2
0
    public static void ExportTSV()
    {
        var tmp = new List <EB.Language>();

        tmp.Add(EB.Language.English);
        tmp.AddRange(Languages);

        foreach (var locale in tmp)
        {
            EB.LocFile file     = new EB.LocFile(LoadAllFromResources(locale, new string[] { "all" }));
            var        contents = file.WriteTSV();
            File.WriteAllText(locale + ".txt", "\r\n" + contents, System.Text.Encoding.Unicode);
        }
    }
Exemplo n.º 3
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
                }
        }
Exemplo n.º 4
0
    public static void BuildTranslationsToBundles()
    {
        foreach (var locale in Languages)
        {
            var local = LoadAllFromResources(locale, new string[] { "all" });

            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(locale);
            var dir  = "Assets/Bundles/Languages";
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            File.WriteAllBytes(Path.Combine(dir, code + ".txt"), bytes);
        }
    }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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();
    }