/// <summary> /// Gets the dictionary item for a specified language. Otherwise returns the fallback string. /// </summary> /// <param name="key">The dictionary key.</param> /// <param name="fallback">The fallback.</param> /// <param name="languageId">The language id.</param> /// <returns> /// Returns the value of a dictionary item from a language id, or the fallback string. /// </returns> public static string GetDictionaryItem(string key, string fallback, int languageId) { if (Dictionary.DictionaryItem.hasKey(key)) { var item = new Dictionary.DictionaryItem(key); return item.Value(languageId); } return fallback; }
private string dictinaryItem(string alias) { if (alias.Substring(1, 0) == "#") { if (Dictionary.DictionaryItem.hasKey(alias.Substring(1))) { Dictionary.DictionaryItem di = new Dictionary.DictionaryItem(alias.Substring(1)); if (di != null && !string.IsNullOrEmpty(di.Value())) return di.Value(); } } return alias + " " + alias.Substring(1); }
public static String ItemForKeyAndLanguage(String key, String languageCode) { ILanguage language = ApplicationContext.Current.Services.LocalizationService.GetAllLanguages().First(x => x.IsoCode.Equals(languageCode)); Dictionary.DictionaryItem dictionaryItem = new Dictionary.DictionaryItem(key); return dictionaryItem.Value(language.Id); }
static string DictionaryReplace(string text) { if (!text.StartsWith("#")) return text; else { Language lang = Language.GetByCultureCode(System.Threading.Thread.CurrentThread.CurrentCulture.Name); if (lang != null) { if (Dictionary.DictionaryItem.hasKey(text.Substring(1, text.Length - 1))) { Dictionary.DictionaryItem di = new Dictionary.DictionaryItem(text.Substring(1, text.Length - 1)); return di.Value(lang.id); } } return "[" + text + "]"; } }