Ejemplo n.º 1
0
        /// <summary>
        /// Localize a string according to a specific culture and specified resource type
        /// </summary>
        /// <param name="resourceSource"></param>
        /// <param name="culture"></param>
        /// <param name="key"></param>
        /// <param name="args"></param>
        /// <returns>localized string</returns>
        public string GetLocalizedString(Type resourceSource, string culture, string key, params object[] args)
        {
            var sw = new StringWriter();

            GenericResourceReader.GetValue(resourceSource, culture, key, args).WriteTo(sw, HtmlEncoder.Default);

            return(sw.ToString());
        }
        private IdentityError LocalizedIdentityError(string code, params object[] args)
        {
            var msg = GenericResourceReader.GetValue <T>(string.Empty, code, args);

            return(args == null
                ? new IdentityError {
                Code = code, Description = msg
            }
                : new IdentityError {
                Code = code, Description = string.Format(msg, args)
            });
        }
        private static string GetLoclizedModelBindingError <T>(string code, params object[] args) where T : class
        {
            var msg = GenericResourceReader.GetValue <T>(string.Empty, code, args);

            return(string.Format(msg, args));
        }
Ejemplo n.º 4
0
 public LocalizedHtmlString Text(Type resourceSource, string key, params object[] args)
 {
     return(GenericResourceReader.GetValue(resourceSource, CultureInfo.CurrentCulture.Name, key, args));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Localize a string according to a specific culture and specified resource type
 /// <para>Use in UI side, for backend text localization use GetLocalizedString instead</para>
 /// </summary>
 /// <param name="resourceSource"></param>
 /// <param name="culture"></param>
 /// <param name="key"></param>
 /// <param name="args"></param>
 /// <returns>LocalizedHtmlString</returns>
 public LocalizedHtmlString GetLocalizedHtmlString(Type resourceSource, string culture, string key, params object[] args)
 {
     return(GenericResourceReader.GetValue(resourceSource, culture, key, args));
 }