I would like to provide my own resource string localization for languages not included in the ACT. I have put in a pull request that allows developers to insert their own translations. Can someone please provide feedback?
Comments: __MikhailTymchukDX__ - I pass the locale key as a query string parameter to my IHttpHandler. I'm happy to hear about any improvements or alternate solutions. The method Localization.GetLocalizationScriptReferences() method yields the results from ExternalScriptReferences(localeKey). ExternalScriptReferences is a function that takes the locale key and returns a ScriptReference. I set the ExternalScriptReference to the following method: ``` public static ScriptReference ScriptReferenceUrl(string culture) { return new ScriptReference("~/actresources.ashx?c=" + culture); } ``` The handler looks like the following. I am only localizing the word Today in my handler. The method LocalizeForSpecificCulture does a cache/database lookup for the localized version of "Today {0}" using the given culture information: ``` /// <summary> /// This handler is used for localizing AJAX Control Toolkit resources strings /// </summary> public class AjaxControlToolkitResourceHandler : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { try { string culture = context.Request.QueryString["c"]; CultureInfo cultureInfo = new CultureInfo(culture); if (!string.IsNullOrWhiteSpace(culture) && cultureInfo != null) { // Currently, only handle localizing the text "Today" on the CalendarExtender control. string resourceString = string.Format("Sys.Extended.UI.Localization[\"{0}\"]={{ \"Calendar_Today\": \"{1}\" }}" , culture , LocalizeForSpecificCulture("Today: {0}", cultureInfo)); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.ContentType = "text/javascript"; context.Response.Write(resourceString); } } catch (Exception ex) { // Log Error } } } ```
Comments: __MikhailTymchukDX__ - I pass the locale key as a query string parameter to my IHttpHandler. I'm happy to hear about any improvements or alternate solutions. The method Localization.GetLocalizationScriptReferences() method yields the results from ExternalScriptReferences(localeKey). ExternalScriptReferences is a function that takes the locale key and returns a ScriptReference. I set the ExternalScriptReference to the following method: ``` public static ScriptReference ScriptReferenceUrl(string culture) { return new ScriptReference("~/actresources.ashx?c=" + culture); } ``` The handler looks like the following. I am only localizing the word Today in my handler. The method LocalizeForSpecificCulture does a cache/database lookup for the localized version of "Today {0}" using the given culture information: ``` /// <summary> /// This handler is used for localizing AJAX Control Toolkit resources strings /// </summary> public class AjaxControlToolkitResourceHandler : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { try { string culture = context.Request.QueryString["c"]; CultureInfo cultureInfo = new CultureInfo(culture); if (!string.IsNullOrWhiteSpace(culture) && cultureInfo != null) { // Currently, only handle localizing the text "Today" on the CalendarExtender control. string resourceString = string.Format("Sys.Extended.UI.Localization[\"{0}\"]={{ \"Calendar_Today\": \"{1}\" }}" , culture , LocalizeForSpecificCulture("Today: {0}", cultureInfo)); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.ContentType = "text/javascript"; context.Response.Write(resourceString); } } catch (Exception ex) { // Log Error } } } ```