示例#1
0
        public string Localize(string key, params string[] formatParams)
        {
            LocalizerStorage storage;

            if (!storages.TryGetValue(locale, out storage))
            {
                storages.Add(locale, storage = new LocalizerStorage(locale));
            }

            var localized = storage.Get(locale, key);

            if (localized == null)
            {
                return(key);
            }

            if (formatParams == null)
            {
                return(localized);
            }

            try
            {
                return(string.Format(localized, formatParams));
            }
            catch (FormatException)
            {
                ClientModel.Logger.WriteWarning("Broken localization for key {0}", key);
                return(string.Empty);
            }
        }
示例#2
0
        public string Localize(string key, params string[] formatParams)
        {
            LocalizerStorage storage;

              if (!storages.TryGetValue(locale, out storage))
            storages.Add(locale, storage = new LocalizerStorage(locale));

              var localized = storage.Get(locale, key);
              if (localized == null)
            return key;

              if (formatParams == null)
            return localized;

              try
              {
            return string.Format(localized, formatParams);
              }
              catch (FormatException)
              {
            ClientModel.Logger.WriteWarning("Broken localization for key {0}", key);
            return string.Empty;
              }
        }