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); } }
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(); }