public static LanguageFile WriteNewLanguageFile(Languages language, LanguageFile file) { string filePath = Application.dataPath + DirectoryPath + language.ToString() + ".lang"; file.fileLanguage = language; Directory.CreateDirectory(Application.dataPath + DirectoryPath); File.WriteAllText(filePath, file.GetJsonFormat()); AssetDatabase.Refresh(); return(file); }
public void GenerateLanguageFile() { LanguageFile languagesFile = new LanguageFile(); fileKeys.ForEach(key => { languagesFile.SetEntry(key); }); string filePath = Application.dataPath + DirectoryPath + "LanguageXX.lang"; File.WriteAllText(filePath, languagesFile.GetJsonFormat()); AssetDatabase.Refresh(); }
public static void WriteNewKeysToLanguageFile(Languages language, List <string> keys, List <string> content = null) { string filePath = Application.dataPath + DirectoryPath + language.ToString() + ".lang"; LanguageFile languagesFile = new LanguageFile(); if (File.Exists(filePath)) { languagesFile = JsonUtility.FromJson <LanguageFile>(File.ReadAllText(filePath)); } for (int i = 0; i < keys.Count; i++) { if (content != null) { languagesFile.SetEntry(keys[i], new LanguageFileEntry(keys[i], content[i])); } else { languagesFile.SetEntry(keys[i]); } } File.WriteAllText(filePath, languagesFile.GetJsonFormat()); }