static string GetLanguageFileContents(string sheetTitle) { if (LocalizationServerManager.Instance.HasLanguageFile(currentLanguage.ToString(), sheetTitle)) { return(LocalizationServerManager.Instance.GetLanguageFileContents(currentLanguage.ToString(), sheetTitle)); } else { TextAsset ta = (TextAsset)Resources.Load("Languages/" + currentLanguage + "_" + sheetTitle, typeof(TextAsset)); return(ta.text); } }
public AudioClip GetAudioByName(SoundType soundType, LanguageCode lang, string soundName) { AudioClip fetchAudio = null; string langKey = lang.ToString(); string soundToSearch = soundName + "_" + langKey; try { switch (soundType) { case SoundType.Questions: fetchAudio = QuestionAudioClips[langKey][soundToSearch]; break; case SoundType.Subtitles: fetchAudio = SubtitlesAudioClips[langKey][soundToSearch]; break; } } catch (Exception) { fetchAudio = null; throw; } return(fetchAudio); }
public static Dictionary <int, string> ReadErrorTextData(LanguageCode lang) { Dictionary <int, string> _dic_ErrorTranslateText = new Dictionary <int, string>(); TextAsset _txtAsset = Resources.Load(string.Format("TextData/{0}/{1}", lang.ToString(), "ErrorCode")) as TextAsset; // LanguageCOde 정의했지만 해당언어 데이터가 없는 경우 리턴 떄리자 if (_txtAsset == null) { return(_dic_ErrorTranslateText); } string _jsonData = _txtAsset.text; object _jsonObj = MiniJSON.Json.Deserialize(_jsonData); List <object> _lstData = (List <object>)_jsonObj; #if UNITY_EDITOR if (_lstData.Count == 0 || _lstData == null) { Debug.LogError("TEXT DATA IS NULL OR EMPTY"); } #endif int _idx = 0; for (int i = 0; i < _lstData.Count; i++) { Dictionary <string, object> _dicData = (Dictionary <string, object>)_lstData[i]; _idx = Convert.ToInt16(_dicData[JsonKey.idx]); _dic_ErrorTranslateText[_idx] = Convert.ToString(_dicData[JsonKey.TEXT]); } return(_dic_ErrorTranslateText); }
public static Phrase FindPhrase(string in_selected_lang, LanguageCode code) { //For the currently selected language find the translated phrase. string err = "No translation for '" + in_selected_lang + "' exists for the currently seelcted lang: '" + code.ToString() + "'."; Dictionary <int, Phrase> dict = null; if (Phrases.Lexicon.TryGetValue(code, out dict) == false) { Globals.LogError(err); //Return bad phrase. return(null); } Phrase trans = null; if (dict.TryGetValue(in_selected_lang.GetHashCode(), out trans) == false) { Globals.LogError(err); return(null); } return(trans); }
private static string GetDescription(LanguageCode value) { FieldInfo field = typeof(LanguageCode).GetField(value.ToString()); return(field.GetCustomAttributes(typeof(DescriptionAttribute), false) .Cast <DescriptionAttribute>() .Select(x => x.Description) .FirstOrDefault()); }
private string GetName(List <VmJsonTypeName> names, LanguageCode code) { string result = ""; if (names != null) { result = names.Where(x => x.Language == code.ToString()).Select(x => x.Name).FirstOrDefault(); } return(result); }
public static string StringValue(this LanguageCode lc) { switch (lc) { case LanguageCode.Facet: return("00"); break; default: return(lc.ToString().ToLower()); } }
override protected PhraseData CreateData(Dictionary <string, object> dict, DatabaseObject db, LanguageCode language) { var data = new PhraseData(); data.Id = ToString(dict["Id"]); data.Active = (ToInt(dict["Active"]) == 1); if (!data.Active) { return(null); // Skip this data if inactive } string langKey = language.ToString().ToUpper()[0] + language.ToString().Substring(1); data.Text = ToString(dict[langKey]); data.Category = ParseEnum <PhraseDataCategory>(data, dict["Category"]); data.Linked = ToString(dict["Linked"]); data.Words = ParseIDArray <WordData, WordTable>(data, (string)dict["Words"], db.GetWordTable()); data.Answers = ParseIDArray <WordData, WordTable>(data, (string)dict["Answers"], db.GetWordTable()); data.Complexity = ToFloat(dict["Complexity"]); return(data); }
private IEnumerator FetchAndReadLanguageJson() { string languagesFilePath = Application.streamingAssetsPath + "/LanguageFiles"; DirectoryInfo directoryInfo = new DirectoryInfo(languagesFilePath); FileInfo[] allFiles = directoryInfo.GetFiles("*.json"); LanguagesTable = new Hashtable(); foreach (var item in allFiles) { using (UnityWebRequest languageFileReader = UnityWebRequest.Get(item.FullName)) { yield return(languageFileReader.SendWebRequest()); if (languageFileReader.isNetworkError || languageFileReader.isHttpError) { Debug.LogWarning("Couldn't found JSON file for: " + item.FullName); } else { JObject languageJson = JObject.Parse(languageFileReader.downloadHandler.text); string lang = languageJson["Language"].ToString(); LanguageCode thisLangCode = ReturnLanguageCodeFromString(lang); LanguagesTable[thisLangCode] = new Hashtable(); Hashtable subs = languageJson["Subtitles"].ToObject <Hashtable>(); foreach (DictionaryEntry entry in subs) { if (!(LanguagesTable[thisLangCode] as Hashtable).ContainsKey(entry.Key)) { (LanguagesTable[thisLangCode] as Hashtable).Add(entry.Key, entry.Value); } } DebugConsole.instance.Languages.text += thisLangCode.ToString() + "\n"; } } } #if UNITY_STANDALONE Debug.Log("Translations loaded"); #endif LANGUAGESREADY = true; }
private int GetCodeIndex(LanguageCode code) { int codeIndex = 0; for (int i = 0; i < m_LanguageInfoList.Count; i++) { if (code.ToString().Equals(m_LanguageInfoList[i].LanguageCodeName)) { codeIndex = i; break; } } return(codeIndex); }
private static VmPhone CreateVm(ServiceChargeTypeEnum?serviceChargeType, PhoneNumberTypeEnum?phoneNumberType, LanguageCode?languageCode) { return(new VmPhone { ChargeDescription = "description", Number = "456789", DialCode = new VmDialCode() { Id = new Guid() }, AdditionalInformation = "info", ChargeType = serviceChargeType?.ToString().GetGuid() ?? Guid.Empty, TypeId = phoneNumberType?.ToString().GetGuid() ?? Guid.Empty, LanguageId = languageCode?.ToString().GetGuid() ?? Guid.Empty }); }
public override string ToString() { var localizedData = _translatable.GetI18N(); if (localizedData == null) { return(_fullPath); } if (_hasLanguageSet == false) { return(localizedData.GetText(_fullPath)); } return(localizedData.GetText(_fullPath, _language.ToString())); }
/// <summary> /// Change current language. /// Set default if language not initialized or recognized. /// </summary> /// <param name="langCode">Language code</param> public void setLanguage(LanguageCode langCode) { if (_langs.ContainsKey(langCode)) { _gameLang = langCode; } else { _gameLang = _defaultLang; Debug.LogError(string.Format("Language {0} not recognized! Using default language.", langCode)); } PlayerPrefs.SetString(GAME_LANG, _gameLang.ToString()); if (OnLanguageChanged != null) { OnLanguageChanged(_gameLang); } if (_useCustomFonts) { I18NFonts newFont = null; _currentCustomFont = null; if (_langFonts != null && _langFonts.Count > 0) { foreach (I18NFonts f in _langFonts) { if (f.lang == _gameLang) { newFont = f; _currentCustomFont = f; break; } } } if (OnFontChanged != null) { OnFontChanged(newFont); } } else { _currentCustomFont = null; } }
void SaveSettingsFile() { if (settings == null) { settings = (LocalizationSettings)ScriptableObject.CreateInstance(typeof(LocalizationSettings)); string settingsPath = Path.GetDirectoryName(settingsAssetPath); if (!Directory.Exists(settingsPath)) { Directory.CreateDirectory(settingsPath); AssetDatabase.ImportAsset(settingsPath); } AssetDatabase.CreateAsset(settings, settingsAssetPath); } settings.defaultLangCode = langCode.ToString(); settings.useSystemLanguagePerDefault = useSystemLang; EditorUtility.SetDirty(settings); }
public LocalizationManager(TextAsset localization, List <LanguageInfo> LanguageInfoList) { m_LanguageInfoList = LanguageInfoList; LanguageCode code; if (PlayerPrefs.HasKey(LocalizatioCode)) { string codeName = PlayerPrefs.GetString(LocalizatioCode, defaultCode.ToString()); code = (LanguageCode)Enum.Parse(typeof(LanguageCode), codeName); } else { code = GetSystemLanguageCode(); } LocalizatioCodeIndex = GetCodeIndex(code); ReadCSV(localization); }
/// <summary> /// Serializes with the specified writer. /// </summary> /// <param name="writer">Writer.</param> public override void Serialize(XmlWriter writer) { writer.WriteStartElement("DefineFont2Tag"); writer.WriteAttributeString("FontId", fontId.ToString()); bool fontFlagsWideCodes = this.glyphShapesTable.IsWideCodes; bool fontFlagsWideOffsets = HasWideOffsets(); bool fontFlagsHasLayout = HasLayoutInfo(); writer.WriteElementString("FontFlagsHasLayout", fontFlagsHasLayout.ToString()); writer.WriteElementString("FontFlagsShiftJIS", fontFlagsShiftJIS.ToString()); writer.WriteElementString("FontFlagsANSI", fontFlagsANSI.ToString()); writer.WriteElementString("FontFlagsWideOffsets", fontFlagsWideOffsets.ToString()); writer.WriteElementString("FontFlagsWideCodes", fontFlagsWideCodes.ToString()); writer.WriteElementString("FontFlagsItalic", fontFlagsItalic.ToString()); writer.WriteElementString("FontFlagsBold", fontFlagsBold.ToString()); writer.WriteElementString("LanguageCode", languageCode.ToString()); writer.WriteElementString("FontNameLength", fontName.Length.ToString()); writer.WriteElementString("FontName", fontName.ToString()); //if (offsetTable != null) // writer.WriteElementString("OffsetTableLenght", offsetTable.Length.ToString()); //writer.WriteElementString("CodeTableOffset", codeTableOffset.ToString()); if (glyphShapesTable != null) { glyphShapesTable.Serialize(writer); } if (fontFlagsHasLayout) { writer.WriteElementString("FontAscent", fontAscent.ToString()); writer.WriteElementString("FontDescent", fontDescent.ToString()); writer.WriteElementString("FontLeading", fontLeading.ToString()); writer.WriteElementString("FontAdvanceTable", fontAdvanceTable.Count.ToString()); fontBoundsTable.Serialize(writer); fontKerningTable.Serialize(writer); } writer.WriteEndElement(); }
public static Dictionary <int, string> ReadTextData(LanguageCode _lang) { // 지역 transtext 컬랙션 Dictionary <int, string> _dic_TranslateText = new Dictionary <int, string>(); string _path = string.Format("TextData/{0}/{1}", _lang.ToString(), "TextData"); TextAsset _txtAset = Resources.Load(_path) as TextAsset; // LanguageCOde 정의했지만 데이터가 없는 경우 리턴 떄리자 if (_txtAset == null) { return(_dic_TranslateText); } string _jsonData = _txtAset.text; object _jsonObj = MiniJSON.Json.Deserialize(_jsonData); // 라이브러리 json 파서 List <object> _lstData = (List <object>)_jsonObj; #if UNITY_EDITOR if (_lstData.Count == 0 || _lstData == null) { Debug.LogError("TEXT DATA IS NULL OR EMPTY"); } #endif int _idx = 0; for (int i = 0; i < _lstData.Count; i++) { Dictionary <string, object> _dicData = (Dictionary <string, object>)_lstData[i]; _idx = Convert.ToInt32(_dicData[JsonKey.IDX]); string _text = Convert.ToString(_dicData[JsonKey.TEXT]); //정보담기 _dic_TranslateText[_idx] = _text; /*int _mainKnd = _idx >> 7; // 인덱스 번호를 2진수 비트연산으로 대분류 번호를 추출 * int _subKnd = (_idx & ((1 << 7) - 1));// ((1<<7)-1) 클리어라 생각... idx 추출 * * switch (_mainKnd) * { * case 0: TimeText[_subKnd] = _text; break; * case 1: ItTpText[_subKnd] = _text; break; * } */ //switch (_TrText) //{ // case TRANSLATE_TEXT.Combat: Dic_TranslateText[_TrText] = _text; break; // case TRANSLATE_TEXT.Store: Dic_TranslateText[_TrText] = _text; break; // case TRANSLATE_TEXT.Clan: Dic_TranslateText[_TrText] = _text; break; // case TRANSLATE_TEXT.Formation: Dic_TranslateText[_TrText] = _text; break; //} } // end of for //반환 return(_dic_TranslateText); }
public Guid Get(LanguageCode key) { return(this.cacheData[key.ToString()]); }
public bool Filter(Guid languageId, LanguageCode filterBy) { return(languageId == this.cacheData[filterBy.ToString()]); }
/// <summary> /// Saves the current configuration to CONFIGFILE. /// </summary> public virtual void Save() { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; // init writer XmlWriter writer = XmlWriter.Create(ConfigFile, settings); // begin writer.WriteStartDocument(); writer.WriteStartElement(XMLTAG_CONFIGURATION); /******************************************************************************/ // PART I: RESOURCES writer.WriteStartElement(XMLTAG_RESOURCES); writer.WriteAttributeString(XMLATTRIB_VERSION, ResourcesVersion.ToString()); writer.WriteAttributeString(XMLATTRIB_PATH, ResourcesPath.ToString().ToLower()); writer.WriteAttributeString(XMLATTRIB_PRELOADROOMS, PreloadRooms.ToString().ToLower()); writer.WriteAttributeString(XMLATTRIB_PRELOADOBJECTS, PreloadObjects.ToString().ToLower()); writer.WriteAttributeString(XMLATTRIB_PRELOADROOMTEXTURES, PreloadRoomTextures.ToString().ToLower()); writer.WriteAttributeString(XMLATTRIB_PRELOADSOUND, PreloadSound.ToString().ToLower()); writer.WriteAttributeString(XMLATTRIB_PRELOADMUSIC, PreloadMusic.ToString().ToLower()); writer.WriteEndElement(); /******************************************************************************/ // PART II: Connections writer.WriteStartElement(XMLTAG_CONNECTIONS); writer.WriteAttributeString(XMLATTRIB_SELECTEDINDEX, SelectedConnectionIndex.ToString()); for (int i = 0; i < connections.Count; i++) { // connection writer.WriteStartElement(XMLTAG_CONNECTION); writer.WriteAttributeString(XMLATTRIB_NAME, connections[i].Name); writer.WriteAttributeString(XMLATTRIB_HOST, connections[i].Host); writer.WriteAttributeString(XMLATTRIB_PORT, connections[i].Port.ToString()); writer.WriteAttributeString(XMLATTRIB_STRINGDICTIONARY, connections[i].StringDictionary); writer.WriteAttributeString(XMLATTRIB_USERNAME, connections[i].Username); writer.WriteAttributeString(XMLATTRIB_PASSWORD, String.Empty); writer.WriteAttributeString(XMLATTRIB_CHARACTER, connections[i].Character); // ignorelist writer.WriteStartElement(XMLTAG_IGNORELIST); for (int j = 0; j < connections[i].IgnoreList.Count; j++) { writer.WriteStartElement(XMLTAG_IGNORE); writer.WriteAttributeString(XMLATTRIB_NAME, connections[i].IgnoreList[j]); writer.WriteEndElement(); } writer.WriteEndElement(); // groups writer.WriteStartElement(XMLTAG_GROUPS); foreach (Group group in connections[i].Groups) { writer.WriteStartElement(XMLTAG_GROUP); writer.WriteAttributeString(XMLATTRIB_NAME, group.Name); foreach (GroupMember member in group.Members) { writer.WriteStartElement(XMLTAG_MEMBER); writer.WriteAttributeString(XMLATTRIB_NAME, member.Name); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndElement(); /******************************************************************************/ // PART III: Language writer.WriteStartElement(XMLTAG_LANGUAGE); writer.WriteAttributeString(XMLATTRIB_VALUE, language.ToString()); writer.WriteEndElement(); /******************************************************************************/ // PART IV: Aliases writer.WriteStartElement(XMLTAG_ALIASES); for (int i = 0; i < aliases.Count; i++) { // alias writer.WriteStartElement(XMLTAG_ALIAS); writer.WriteAttributeString(XMLATTRIB_KEY, aliases[i].Key); writer.WriteAttributeString(XMLATTRIB_VALUE, aliases[i].Value); writer.WriteEndElement(); } writer.WriteEndElement(); /******************************************************************************/ // let deriving classes write their stuff WriteXml(writer); // end writer.WriteEndElement(); writer.WriteEndDocument(); // close writer writer.Close(); }
public Guid Get(LanguageCode key) { return(Get(key.ToString())); }
public string GetLocalizedString(LanguageCode identifier) => identifier.ToString();
public FakeHostedPayment SetPayPageLanguageCode(LanguageCode languageCode) { LanguageCode = languageCode.ToString().ToLower(); return this; }
public FakeHostedPayment SetPayPageLanguageCode(LanguageCode languageCode) { LanguageCode = languageCode.ToString().ToLower(); return(this); }
/// <summary> /// 设置语言 /// </summary> /// <param name="code"></param> public void SetLanguage(LanguageCode code) { LocalizatioCodeIndex = GetCodeIndex(code); PlayerPrefs.SetString(LocalizatioCode, code.ToString()); LanguageEvent?.Invoke(); }
public PackagedUserProfile(LiteracyProfile u, UserPreferences p, LanguageCode l) { userProblems = u; preferences = p; language = l.ToString(); }
public PaymentMethodPayment SetPayPageLanguageCode(LanguageCode languageCode) { LanguageCode = languageCode.ToString().ToLower(); return this; }
private void LocalizedContentManager_OnLanguageChange(LanguageCode code) { String cultureString = code.ToString(); SpecificCulture = CultureInfo.CreateSpecificCulture(cultureString); }
public DifficultiesDescription( LanguageArea[] p, Difficulty[][] d, LanguageCode l) { problemsIndex=p;problems=d;language=l.ToString(); }
public ITranslationDefinitions <ServiceChannelVersioned, TOut> AddWebPagesDefinition <TOut>(ITranslationDefinitions <ServiceChannelVersioned, TOut> definition, LanguageCode languageCode) where TOut : IWebPages { return(definition.AddCollection(i => i.WebPages.OrderBy(x => x.WebPage.OrderNumber).ThenBy(x => x.WebPage.Created).Where(x => languageCache.Get(languageCode.ToString()) == x.WebPage.LocalizationId), o => o.WebPages)); }
public async Task SetLanguageAsync(LanguageCode language) { await _cache.InvalidateAll(); await _cache.InsertObject(nameof(LanguageCode), language.ToString(), null); }
void SaveSettingsFile() { settings.defaultLangCode = langCode.ToString(); settings.useSystemLanguagePerDefault = useSystemLang; EditorUtility.SetDirty(settings); }
public PaymentMethodPayment SetPayPageLanguageCode(LanguageCode languageCode) { LanguageCode = languageCode.ToString().ToLower(); return(this); }
private void Awake() { DialogueDao.DatabasePath = "URI=file:" + Application.dataPath + "/Databases/Dialogues.db"; dialogueDictionary = DialogueDao.GetAll(languageCode.ToString().ToLower()); }