/// <summary> /// Creates a new Localized Object from another /// </summary> /// <param name="other">The object to copy</param> public LocalizedObject(LocalizedObject other) { if (other != null) { objectType = other.ObjectType; textValue = other.TextValue; overrideLocalizedObject = other.OverrideLocalizedObject; } }
/// <summary> /// Helper method that checks and gets the language override code of the object is overridden. /// If it's not - it will return the currently loaded language. /// </summary> string CheckLanguageOverrideCode(LocalizedObject localizedObject) { if (localizedObject == null) { return(loadedCultureInfo.languageCode); } string objectLanguage = localizedObject.OverrideLocalizedObject ? localizedObject.OverrideObjectLanguageCode : loadedCultureInfo.languageCode; if (string.IsNullOrEmpty(objectLanguage)) { objectLanguage = loadedCultureInfo.languageCode; } return(objectLanguage); }
internal T GetAsset <T>(string key) where T : UnityEngine.Object { LocalizedObject localizedObject = GetLocalizedObject(key); if (localizedObject != null) { return(AssetLoader.LoadAsset <T>(key, CheckLanguageOverrideCode(localizedObject))); } if (VerboseLogging) { Debug.LogError("Не удалось получить ассет с ключом: " + key + " как тип ассета:" + typeof(T).ToString()); } return(default(T)); }
internal string GetTextValue(string key) { LocalizedObject localizedObject = GetLocalizedObject(key); if (localizedObject != null) { return(localizedObject.TextValue); } if (VerboseLogging) { Debug.LogError("LanguageManager.cs: Неправильный ключ:" + key + ". Не удалось получить значение языка."); } return(null); }
static void ReadData(XmlReader reader, SortedDictionary <string, LocalizedObject> loadedLanguageDictionary) { string key = string.Empty; string value = string.Empty; if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { if (reader.Name == "name") { key = reader.Value; } } } //Move back to the element reader.MoveToElement(); //Read the child nodes if (reader.ReadToDescendant("value")) { do { value = reader.ReadElementContentAsString(); }while (reader.ReadToNextSibling("value")); } //Add the localized parsed values to the localizedObjectDict LocalizedObject newLocalizedObject = new LocalizedObject(); newLocalizedObject.ObjectType = LocalizedObject.GetLocalizedObjectType(key); newLocalizedObject.TextValue = value; if (newLocalizedObject.ObjectType != LocalizedObjectType.STRING && newLocalizedObject.TextValue != null && newLocalizedObject.TextValue.StartsWith("override=")) { newLocalizedObject.OverrideLocalizedObject = true; newLocalizedObject.OverrideObjectLanguageCode = newLocalizedObject.TextValue.Substring("override=".Length); } loadedLanguageDictionary.Add(LocalizedObject.GetCleanKey(key, newLocalizedObject.ObjectType), newLocalizedObject); }