/// <summary> /// Reloads the entire data by switching the language. /// Be careful, we are currently not able to refresh the elements that have already asked for a translation. This will come in the future with an event system. /// </summary> /// <param name="newLang"></param> public void ReloadAll(TranslationConstants.Languages newLang) { if (engine.currentLang == newLang) { return; } engine.LoadAllUnlocalizedStrings(newLang); }
/// <summary> /// We load all the data contained in the JSON file associated to this language and store it in the UnlocalizedString dictionary. /// </summary> /// <param name="lang"></param> public void LoadAllUnlocalizedStrings(TranslationConstants.Languages lang) { currentLang = lang; InitParser(lang); UnlocalizedString[] allstrings = parser.Unmarshall<UnlocalizedString>(); UnocalizedStrings = new Dictionary<string, string>(); for (int i = 0; i < allstrings.Length; i++) { UnocalizedStrings.Add(allstrings[i].key, allstrings[i].value); } }
private void InitParser(TranslationConstants.Languages lang) { if (!TranslationConstants.UnlocalizedFilePath.ContainsKey(lang)) { Debug.LogWarning("TranslationConstants does not contains a file for the language :" + lang + ". Default language FR_fr was selected instead."); parser = new JSONParser(TranslationConstants.UnlocalizedFilePath[TranslationConstants.Languages.FR_fr]); } else { parser = new JSONParser(TranslationConstants.UnlocalizedFilePath[lang]); } }
public TranslationEngine(TranslationConstants.Languages lang) { LoadAllUnlocalizedStrings(lang); Debug.Log("Translation Engine is ready to work."); }