Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you go with the recommended solution (1) (i.e. as in K. Scott Allen's blog):</p> <p>For those of you trying to use explicit localization expressions (aka declarative resource binding expressions), e.g. <code>&lt;%$ Resources, MyResource:SomeString %&gt;</code></p> <pre><code>public class AppResourceProvider : IResourceProvider { private readonly string _ResourceClassName; ResourceManager _ResourceManager = null; public AppResourceProvider(string className) { _ResourceClassName = className; } public object GetObject(string resourceKey, System.Globalization.CultureInfo culture) { EnsureResourceManager(); if (culture == null) { culture = CultureInfo.CurrentUICulture; } return _ResourceManager.GetObject(resourceKey, culture); } public System.Resources.IResourceReader ResourceReader { get { // Not needed for global resources throw new NotSupportedException(); } } private void EnsureResourceManager() { var assembly = typeof(Resources.ResourceInAppToGetAssembly).Assembly; String resourceFullName = String.Format("{0}.Resources.{1}", assembly.GetName().Name, _ResourceClassName); _ResourceManager = new global::System.Resources.ResourceManager(resourceFullName, assembly); _ResourceManager.IgnoreCase = true; } } public class AppResourceProviderFactory : ResourceProviderFactory { // Thank you, .NET, for providing no way to override global resource providing w/o also overriding local resource providing private static Type ResXProviderType = typeof(ResourceProviderFactory).Assembly.GetType("System.Web.Compilation.ResXResourceProviderFactory"); ResourceProviderFactory _DefaultFactory; public AppResourceProviderFactory() { _DefaultFactory = (ResourceProviderFactory)Activator.CreateInstance(ResXProviderType); } public override IResourceProvider CreateGlobalResourceProvider(string classKey) { return new AppResourceProvider(classKey); } public override IResourceProvider CreateLocalResourceProvider(string virtualPath) { return _DefaultFactory.CreateLocalResourceProvider(virtualPath); } } </code></pre> <p>Then, add this to your web.config:</p> <pre><code> &lt;globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="utf-8" culture="en-US" uiCulture="en" resourceProviderFactoryType="Vendalism.ResourceProvider.AppResourceProviderFactory" /&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload