Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
		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 + "]";
			}
		}