public District(DistrictTypes type, Byte id, LanguageCodes langCode = LanguageCodes.EN) { _type = type; _lang = langCode; Type = (Byte)((Byte)type + (Byte)langCode); Id = id; }
private async Task UpdateJumpList() { if (!JumpList.IsSupported()) { return; } try { JumpList jumpList = await JumpList.LoadCurrentAsync(); jumpList.SystemGroupKind = JumpListSystemGroupKind.None; jumpList.Items.Clear(); foreach (DirectionViewModel directionViewModel in AvailableDirections) { string itemName = string.Format("{0} → {1}", directionViewModel.OriginLanguage, directionViewModel.DestinationLanguage); string arguments = "dict:" + directionViewModel.OriginLanguageCode + directionViewModel.DestinationLanguageCode; JumpListItem jumpListItem = JumpListItem.CreateWithArguments(arguments, itemName); jumpListItem.Logo = LanguageCodes.GetCountryFlagUri(directionViewModel.OriginLanguageCode); jumpList.Items.Add(jumpListItem); } await jumpList.SaveAsync(); } catch { // in rare cases, SaveAsync may fail with HRESULT 0x80070497: "Unable to remove the file to be replaced." // this appears to be a common problem without a solution, so we simply ignore any errors here } }
/// <summary> /// The user clicked on an item in the list of languages and strings. /// </summary> private void LstWallLanguages_MouseClick(object sender, MouseEventArgs e) { LblWallPrice.Visible = true; LblWallName.Visible = true; //A floor or wall has only 1 string table. STR StringTable = m_CurrentIff.StringTables[0]; foreach (ListViewItem Item in LstWallLanguages.Items) { //We only support selecting one item at a time. if (Item.Selected) { TxtWallName.Visible = true; TxtWallName.Clear(); TxtWallPrice.Visible = true; TxtWallPrice.Clear(); TxtWallStrings.Visible = true; TxtWallStrings.Clear(); LanguageCodes SelectedCode = (LanguageCodes)Enum.Parse(typeof(LanguageCodes), Item.Text); m_CurrentLanguage = SelectedCode; TxtWallName.Text = StringTable.GetString(SelectedCode, ObjectStringIndices.Name); TxtWallPrice.Text = StringTable.GetString(SelectedCode, ObjectStringIndices.Price); TxtWallStrings.Text = StringTable.GetString(SelectedCode, ObjectStringIndices.Description); } } }
public async Task <string?> GetTranslationAsync(LanguageCodes languageCode, TelegramTranslationKeys telegramTranslationKey, bool omitCache = false, CancellationToken token = default) { const double timeoutDays = 1; var key = string.Format(TranslationCacheKeyFormat, languageCode, telegramTranslationKey); if (memoryCache.TryGetValue <string>(key, out var result)) { return(result); } var translation = await PolicySet.ReadPolicy .ExecuteAsync(() => Context.TelegramTranslations .FirstOrDefaultAsync(x => x.Language == languageCode && x.Key == telegramTranslationKey, token)); var value = translation?.Value; if (!string.IsNullOrEmpty(value)) { memoryCache.Set(key, value, new MemoryCacheEntryOptions { SlidingExpiration = TimeSpan.FromDays(timeoutDays) }); } return(value); }
public District(DistrictTypes type, byte id, LanguageCodes langCode = LanguageCodes.EN) { _type = type; _lang = langCode; Type = (byte)((byte)type + (byte)langCode); Id = id; }
public static void SaveStrings() { foreach (KeyValuePair <string, LocalisationMap> languagePair in _localisationMaps) { SystemLanguage languageCode = LanguageCodes.GetLanguageFromCode(languagePair.Key); if (languageCode != SystemLanguage.Unknown) { string resourceName = GetLocalisationMapName(languageCode); string assetsPath = LocalisationProjectSettings.Get()._localisationFolder; string resourcePath = AssetUtils.GetResourcePath(assetsPath) + "/" + resourceName; string filePath = AssetUtils.GetAppllicationPath(); TextAsset asset = Resources.Load(resourcePath) as TextAsset; if (asset != null) { filePath += AssetDatabase.GetAssetPath(asset); } else { filePath += assetsPath + "/" + resourceName + ".xml"; } languagePair.Value._language = LanguageCodes.GetLanguageFromCode(languagePair.Key); languagePair.Value.SortStrings(); Serializer.ToFile(languagePair.Value, filePath); } } _dirty = false; }
public string GetString(string key, SystemLanguage language, SystemLanguage fallBackLanguage) { string text; Dictionary <string, string> localisedString; if (!string.IsNullOrEmpty(key) && _strings.TryGetValue(key, out localisedString)) { if (localisedString.TryGetValue(LanguageCodes.GetLanguageCode(language), out text)) { return(text); } else { Debug.Log("Can't find localised version of string " + key + " for " + language); #if _DEBUG if (fallBackLanguage != SystemLanguage.Unknown && fallBackLanguage != language && localisedString.TryGetValue(LanguageCodes.GetLanguageCode(fallBackLanguage), out text)) { return(text); } else { Debug.Log("Can't find localised version of string " + key); } #endif } } return(string.Empty); }
/// <summary> /// This function sets the current UI culture and resource manager /// </summary> /// <param name="lngCode">LanguageCode</param> /// <returns>True or False.</returns> static internal bool SetLanguage(LanguageCodes lngCode) { try { string languageCulture; if (lngCode == LanguageCodes.English) { m_ResourceManager = new ResourceManager(Constants.RESOURCE_NAME, typeof(ViewBase).Assembly); languageCulture = Common.Constants.ENGLISH_CULTURE; } else if (lngCode == LanguageCodes.Japanese) { m_ResourceManager = new ResourceManager(Constants.RESOURCE_NAME_JP, typeof(ViewBase).Assembly); languageCulture = Common.Constants.JAPANESE_CULTURE; } else { m_ResourceManager = new ResourceManager(Constants.RESOURCE_NAME, typeof(ViewBase).Assembly); languageCulture = Common.Constants.ENGLISH_CULTURE; } const bool languageStatus = true; m_SelectedLanguage = lngCode; return languageStatus; } catch (Exception) { return false; } }//End of the function SetLnaguage.
private static void MakeSureStringsAreLoaded(SystemLanguage language) { if (!_localisationMaps.ContainsKey(LanguageCodes.GetLanguageCode(language))) { LoadStrings(language); } }
/// <summary> /// This function sets the current UI culture and resource manager /// </summary> /// <param name="lngCode">LanguageCode</param> /// <returns>True or False.</returns> static internal bool SetLanguage(LanguageCodes lngCode) { try { string languageCulture; if (lngCode == LanguageCodes.English) { m_ResourceManager = new ResourceManager(Constants.RESOURCE_NAME, typeof(ViewBase).Assembly); languageCulture = Common.Constants.ENGLISH_CULTURE; } else if (lngCode == LanguageCodes.Japanese) { //not included. m_ResourceManager = new ResourceManager(Constants.RESOURCE_NAME_JP, typeof(ViewBase).Assembly); languageCulture = Common.Constants.JAPANESE_CULTURE; } else { m_ResourceManager = new ResourceManager(Constants.RESOURCE_NAME, typeof(ViewBase).Assembly); languageCulture = Common.Constants.ENGLISH_CULTURE; } const bool languageStatus = true; m_SelectedLanguage = lngCode; return(languageStatus); } catch (Exception) { return(false); } } //End of the function SetLnaguage.
public static void Set(string key, SystemLanguage language, string text) { OnPreEditorChange(); _localisationMaps[LanguageCodes.GetLanguageCode(language)].SetString(key, text); OnPostEditorChange(); }
private void OnTranslatedWord(LanguageCodes target, string targetText, string sourceText) { WordTranslation wordT = new WordTranslation(); wordT.country = (Languages)target; wordT.meaning = targetText; db.GetDB().Find(x => x.word.Equals(sourceText)).wordTranslation.Add(wordT); }
public static int GetLanguageIdFromLanguageEnum(LanguageCodes pLanguageCode) { if (Enum.IsDefined(typeof(LanguageCodes), pLanguageCode) == false) { return(-1); } return((int)pLanguageCode); }
public static string Type2Text(LanguageCodes value) { switch (value) { case LanguageCodes.VI: return(Languages.Libs.GetString("vietnamese")); default: return(Languages.Libs.GetString("english")); } }
public static string Get(string key, SystemLanguage language, params LocalisationLocalVariable[] localVariables) { MakeSureStringsAreLoaded(language); string text = _localisationMaps[LanguageCodes.GetLanguageCode(language)].Get(key); text = ReplaceVariables(text, localVariables); return(text); }
public static void UnloadStrings(SystemLanguage language) { if (_localisationMaps.ContainsKey(LanguageCodes.GetLanguageCode(language))) { #if UNITY_EDITOR EditorWarnIfDirty(); #endif _localisationMaps.Remove(LanguageCodes.GetLanguageCode(language)); } }
/// <summary> /// Gets a specific string for a specified language code. /// </summary> /// <param name="LangCode">The language code.</param> /// <param name="Index">The index of the string to retrieve.</param> /// <returns>A string.</returns> public string GetString(LanguageCodes LangCode, ObjectStringIndices Index) { try { return(Strings[LangCode][(int)Index].TranslatedStr); } catch (Exception) { return(""); } }
/// <summary> /// Returns a list of strings for a specified language code. /// </summary> /// <param name="LangCode">The language code to retrieve strings for.</param> /// <returns>A list of strings for the specified language code.</returns> public List <TranslatedString> GetStringList(LanguageCodes LangCode) { if (Strings.ContainsKey(LangCode)) { return(Strings[LangCode]); } else { return(new List <TranslatedString>()); } }
public static string GetRawString(string key, SystemLanguage language) { MakeSureStringsAreLoaded(language); if (_localisationMaps.TryGetValue(LanguageCodes.GetLanguageCode(language), out LocalisationMap map)) { return(map.Get(key, true)); } return(string.Empty); }
public static LanguageCodes FromString(this LanguageCodes _c, string s) { try { return((LanguageCodes)Enum.Parse(typeof(LanguageCodes), s.ToUpper())); } catch { return(LanguageCodes.Unknown); } } // !FromString()
public static bool Exists(string key, SystemLanguage language) { MakeSureStringsAreLoaded(); if (_localisationMaps.TryGetValue(LanguageCodes.GetLanguageCode(language), out LocalisationMap map)) { return(map.IsValidKey(key)); } return(false); }
public static async void UpdatePreferedLanguageByIDAsync(string Accountname, LanguageCodes ID) { using (var Cmd = new SQLiteCommand()) { Cmd.Connection = m_DBConnection; Cmd.CommandText = "UPDATE Accounts SET PreferedLanguageID = " + (int)ID + " WHERE Username = '******'"; Cmd.CommandType = CommandType.Text; await Cmd.ExecuteReaderAsync(); } }
public static string Get(SystemLanguage language, string key, params LocalisationLocalVariable[] localVariables) { MakeSureStringsAreLoaded(language); if (_localisationMaps.TryGetValue(LanguageCodes.GetLanguageCode(language), out LocalisationMap map)) { string text = map.Get(key); text = ReplaceVariables(text, localVariables); return(text); } return("No Localisation Map found for " + language); }
private void FreshChapterView() { if (InvokeRequired) { Invoke(new MethodInvoker(FreshChapterView)); return; } this.Cursor = Cursors.WaitCursor; try { listChapters.Items.Clear(); //fill list foreach (ChapterEntry c in pgc.Chapters) { //don't show short last chapter depending on settings if (pgc.Duration != TimeSpan.Zero && miIgnoreShortLastChapter.Checked && c.Equals(pgc.Chapters.Last()) && (pgc.Duration.Add(-c.Time).TotalSeconds < Settings.Default.ShortChapterSeconds)) { continue; } listChapters.Items.Add(new ListViewItem(new string[] { c.Time.ToShortString(), c.Name })); } if (intIndex < listChapters.Items.Count && listChapters.Items[intIndex] != null) { //select it listChapters.Items[intIndex].Selected = true; //scroll to it listChapters.Items[intIndex].EnsureVisible(); } //update status tsslDuration.Text = "Duration: " + pgc.Duration.ToShortString(); tsslFps.Text = pgc.FramesPerSecond.ToString("0.000") + "fps"; tsslLang.Text = pgc.LangCode + " (" + LanguageCodes.GetName(pgc.LangCode) + ")"; tsslStatus.Text = "Chapters loaded."; //check the current fps foreach (MenuItem mi in menuCurrentFps.MenuItems) { double fps = Convert.ToDouble(mi.Text, new NumberFormatInfo()); mi.Checked = (Math.Round(fps, 3) == Math.Round(pgc.FramesPerSecond, 3)); } } catch (Exception ex) { Trace.WriteLine(ex); } finally { this.Cursor = Cursors.Default; } }
void LoadLangMenu() { menuLang.MenuItems.Clear(); foreach (KeyValuePair <string, string> lang in LanguageCodes.GetLanguages() .Where(kvp => Settings.Default.LangValues.Contains(kvp.Key)).Concat( LanguageCodes.GetLanguages().Where(u => u.Key == "und"))) { menuLang.MenuItems.Add(new MenuItem(lang.Key + " (" + lang.Value + ")", (s, args) => ChangeLang(((MenuItem)s).Tag as string)) { Tag = lang.Key, RadioCheck = true, Checked = lang.Key == (pgc == null ? Settings.Default.DefaultLangCode : pgc.LangCode) }); } menuLang.MenuItems.Add(menuLang.MenuItems.Count - 1, new MenuItem("-")); }
public void UpdateString(string key, SystemLanguage language, string text) { if (!string.IsNullOrEmpty(key)) { Dictionary <string, string> localisedString; if (_strings.TryGetValue(key, out localisedString)) { localisedString[LanguageCodes.GetLanguageCode(language)] = text; } else { _strings.Add(key, new Dictionary <string, string>()); _strings[key].Add(LanguageCodes.GetLanguageCode(language), text); } } }
public static void ReloadStrings(bool warnIfDirty = false) { if (warnIfDirty) { EditorWarnIfDirty(); } string[] languageCodes = new string[_localisationMaps.Keys.Count]; _localisationMaps.Keys.CopyTo(languageCodes, 0); foreach (string languageCode in languageCodes) { SystemLanguage language = LanguageCodes.GetLanguageFromCode(languageCode); LoadStrings(language); } _dirty = false; }
private IEnumerator Process(LanguageCodes sourceLang, List <LanguageCodes> targetLang, string sourceText) { string sourcText = sourceLang.ToString(); bool isError = false; Debug.Log("Word" + " : " + sourceText); foreach (var val in targetLang) { string targetText = val.ToString(); // if Language code has hyphen such as Chinene ... Hyphen not allow in Enums.. if (targetText.Contains("_")) { targetText = targetText.Replace('_', '-'); } string url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + sourcText + "&tl=" + targetText + "&dt=t&q=" + WWW.EscapeURL(sourceText); WWW www = new WWW(url); yield return(www); if (www.isDone) { if (string.IsNullOrEmpty(www.error)) { var N = JSONNode.Parse(www.text);// Json Parser translatedText = N[0][0][0]; print(targetText + " : " + translatedText); OnTranslatedWord(val, translatedText, sourceText); } else { //isError = true; InternetNotWorking(); yield break; } } } if (!isError) { _controller.ValueChange(db.GetDB().Count, db.GetList().Count); db.OnTranslated(); } }
public static LocalisationGlobalVariable[] GetGlobalVariables(string key, SystemLanguage language) { if (_localisationMaps.TryGetValue(LanguageCodes.GetLanguageCode(language), out LocalisationMap map)) { string text = map.Get(key, true); List <LocalisationGlobalVariable> keys = new List <LocalisationGlobalVariable>(); int index = 0; while (index < text.Length) { int variableStartIndex = text.IndexOf(kVariableStartChars, index); if (variableStartIndex != -1) { int variableEndIndex = text.IndexOf(kVariableEndChars, variableStartIndex); if (variableEndIndex == -1) { throw new Exception("Can't find matching end bracket for variable in localised string"); } int variableKeyStartIndex = variableStartIndex + kVariableEndChars.Length + 1; string variableKey = text.Substring(variableKeyStartIndex, variableEndIndex - variableKeyStartIndex); _globalVariables.TryGetValue(variableKey, out GlobalVariable info); keys.Add(new LocalisationGlobalVariable(variableKey, info._version)); index = variableEndIndex + kVariableEndChars.Length; } else { break; } } return(keys.ToArray()); } return(null); }
public static IEnumerable <string> GetAudioLanguages(this IPlayableContent playableContent, string defaultAudioLanguage) { var languageCode = playableContent.GetPreferredAudioLanguage(defaultAudioLanguage); var languageCodes = new List <string> { languageCode }; var languageCodeShort = LanguageCodes.GetTwoLetterCode(languageCode); if (!string.IsNullOrWhiteSpace(languageCodeShort)) { languageCodes.Add(languageCodeShort); } if (languageCode != LanguageCodes.English) { languageCodes.Add(LanguageCodes.English); languageCodes.Add(LanguageCodes.GetTwoLetterCode(LanguageCodes.English)); } return(languageCodes); }
private void GetTargetLanguage(long selectedEnum, string word) { long value = (long)selectedEnum; List <LanguageCodes> list = new List <LanguageCodes>(); int count = 0; int max = System.Enum.GetNames(typeof(LanguageCodes)).Length; while (count < max) { long isOne = (value & 1); value = value >> 1; if (isOne == 1) { list.Add((LanguageCodes)count); } count++; } LanguageCodes sourcecode = (LanguageCodes)sourceLanguage; Translate translate = GameObject.FindObjectOfType <Translate>(); translate.Translation(sourcecode, list, word); }
public static MessageContainer Create(LanguageCodes code) { switch (code) { case LanguageCodes.en_GB: return(new MessageContainer() { IsNotNullMessage = "'{0}' cannot be null.", IsNotNullOrEmptyMessage = "'{0}' cannot be null or empty.", IsNotNullOrWhiteSpaceMessage = "'{0}' cannot be null or whitespace only.", IsNotZeroMessage = "'{0}' cannot be zero.", IsPasswordMessage = "'{0}' is not a valid password. Passwords must be 8 to 30 characters, at least on 1 uppercase letter, at least 1 lowercase letter and at least one number.", IsMinLengthMessage = "'{0}' must be a at least {1} characters.", IsMaxLengthMessage = "'{0}' must be {1} characters or less.", IsExactLengthMessage = "'{0}' must be exactly {1} characters.", IsBetweenLengthMessage = "'{0}' must be at least {1} and at most {2} characters.", IsMessage = "'{0}' does not match the specified criteria.", IsNotMessage = "'{0}' does not match the specified criteria.", IsEmailMessage = "'{0}' is not a valid email address.", IsRegexMessage = "'{0}' does not match the provided regular expression.", IsMatchMessage = "'{0}' did not match the specified criteria.", IsDateMessage = "'{0}' is not a valid date.", IsRuleMessage = "'{0}' failed the provided business rule provided.", // Dates IsGreaterThanMessage = "'{0}' must be greater than '{1}'.", IsGreaterThanOrEqualToMessage = "'{0}' must be greater than or equal to '{1}'.", IsLessThanMessage = "'{0}' must be less than '{1}'.", IsLessThanOrEqualToMessage = "'{0}' must be less than or equal to '{1}'.", IsEqualToMessage = "'{0}' must be equal to '{1}'.", IsBetweenInclusiveMessage = "'{0}' must be between '{1}' and '{2}' (inclusive).", IsBetweenExclusiveMessage = "'{0}' must be between '{1}' and '{2}' (exclusive)." }); default: return(Create(LanguageCodes.en_GB)); } }
public WaterFrontDistrict(Byte id, LanguageCodes langCode = LanguageCodes.EN, Boolean hardCore = false) : base(hardCore ? DistrictTypes.WATERFRONT_HARDCORE : DistrictTypes.WATERFRONT, id, langCode) { }
public FinancialDistrict(Byte id, LanguageCodes langCode = LanguageCodes.EN, Boolean hardCore = false) : base(hardCore ? DistrictTypes.FINANCIAL_HARDCORE : DistrictTypes.FINANCIAL, id, langCode) { }
public bool UpdateLanguageForCompID(int compId, LanguageCodes code) { var LanguageDAL = new LanguageDAL(testing); return LanguageDAL.UpdateLanguageForCompID(compId, code); }
/// <summary> /// Returns a list of strings for a specified language code. /// </summary> /// <param name="LangCode">The language code to retrieve strings for.</param> /// <returns>A list of strings for the specified language code.</returns> public List<TranslatedString> GetStringList(LanguageCodes LangCode) { return Strings[LangCode]; }
public string GetString(LanguageCodes LangCode, int Index) { return Strings[LangCode][Index].TranslatedStr; }
/// <summary> /// Updates a CompID's language code. Does not set language for a CompID /// only updates. /// </summary> /// <param name="compId"></param> /// <param name="code"></param> /// <returns>true or false depending on success</returns> public bool UpdateLanguageForCompID(int compId, LanguageCodes code) { var toUpdate = GetExactRowByCompID(compId); try { using (var db = new BlissBaseContext(testing)) { toUpdate.LangCode = code; db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine("A Exception was thrown when trying to update language code for " + "CompId: " + compId + ". Might be that composite sybol is defined as international"); Debug.WriteLine(e.StackTrace); return false; } }
/// <summary> /// Sets a non international language for a CompID /// </summary> /// <param name="compId"></param> /// <param name="code"></param> /// <returns>true or false depending on success</returns> public bool SetLanguageForCompID(int compId, LanguageCodes code) { var toAdd = new Languages { CompID = compId, LangCode = code }; try { using (var db = new BlissBaseContext(testing)) { db.Languages.Add(toAdd); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine("An exception was thrown when defining composite symbol: " + compId + " as non international, with LanguageCodes: " + code); Debug.WriteLine(e.StackTrace); return false; } }
public static string Type2Text(LanguageCodes value) { switch (value) { case LanguageCodes.VI: return Languages.Libs.GetString("vietnamese"); default: return Languages.Libs.GetString("english"); } }