static void ImportLocaFile(string pPath) { UGBLocaParser parser = new UGBLocaParser(); parser.Parse(pPath); // now that loca is parsed, generating loca files. var languages = parser.GetLanguages(); for (int i = 0; i < languages.Count; i++) { // Load Loca for language LocaData ld = LocaData.Load(languages[i]); // Add all parsed keys to the loca file foreach (UGBLocaParser.CLocaEntry e in parser.GetEntries()) { if (i > 0 && i < e.mTranslations.Length && e.mTranslations[i] != null) { ld.AddText(e.mKey, e.mTranslations[i]); } } // Save Loca file ld.Save(); } AssetDatabase.Refresh(); }
public static LocaData Load(string pLanguageShort) { LocaData lData = new LocaData(); try { TextAsset ta = Resources.Load("loca/loca_" + pLanguageShort) as TextAsset; MemoryStream ms = new MemoryStream(ta.bytes); XmlSerializer s = new XmlSerializer(typeof(XmlLocaData)); XmlLocaData data = s.Deserialize(ms) as XmlLocaData; lData.mXmlData = data; lData.mXmlData.PostRead(); } catch (Exception e) { Debug.LogWarning("Error loading loca file for requested language. " + e.Message); lData.mXmlData = new XmlLocaData(); lData.mXmlData.mLanguage = pLanguageShort; } return(lData); }
private static void AddLocaData(String fileOrigin, LocaData[] data, Dictionary <String, String> p_target) { try { HashSet <String> processedIds = new HashSet <String>(); for (Int32 i = 0; i < data.Length; i++) { LocaData item = data[i]; if (!processedIds.Add(item.ID)) { LegacyLogger.Log("Double LocaID '" + item.ID + "' in " + fileOrigin); continue; } if (String.IsNullOrEmpty(item.Text)) { LegacyLogger.Log("LocaID '" + item.ID + "' has no text", false); continue; } p_target[item.ID] = item.Text.Trim(); } } catch (Exception ex) { LegacyLogger.Log("Error initializing LocaTexts: " + fileOrigin + " " + ex); } }
static void OnPostprocessAllAssets( string[] pImportedAssets, string[] pDeletedAssets, string[] pMovedAssets, string[] pMovedFromAssetsPaths) { foreach (string imported in pImportedAssets) { if (!imported.Contains("loca")) { continue; } UGBLocaParser parser = null; if (imported.EndsWith(".xml")) { parser = new UGBXmlLocaParser(); parser.Parse(imported); } else if (imported.EndsWith(".csv")) { parser = new UGBCsvLocaParser(); parser.Parse(imported); } else { continue; } // now that loca is parsed, generating loca files. var languages = parser.GetLanguages(); for (int i = 0; i < languages.Count; i++) { // Load Loca for language LocaData ld = LocaData.Load(languages[i]); // Add all parsed keys to the loca file foreach (CLocaEntry e in parser.GetEntries()) { if (i < e.mTranslations.Length) { ld.AddText(e.mKey, e.mTranslations[i]); } } // Save Loca file ld.Save(); } AssetDatabase.Refresh(); } }
public static void Refresh() { #if UNITY_EDITOR AllLanguagesNames = GetAllAvailableLanguages(); if (currentLanguage == null || currentLanguage == "") { currentLanguage = "de"; } locaData = LocaData.LoadFromEditor(currentLanguage + ".xml"); #endif }
public void Initialize() { mData = LocaData.Load(GetCurrentLanguageShort()); }
public static void Refresh() { #if UNITY_EDITOR AllLanguagesNames = GetAllAvailableLanguages(); if (currentLanguage == null || currentLanguage == "") currentLanguage = "de"; locaData = LocaData.LoadFromEditor(currentLanguage + ".xml"); #endif }