2 <h2>Resources/Localization</h2>
\r
5 <div class="container">
\r
8 You can now associate a resource to a class or action. For example, our static file
\r
9 controller code uses resource like this:
\r
13 [Resource("Ajax","Castle.MonoRail.Framework.Controllers.Ajax")]
\r
14 [Resource("Effects2", "Castle.MonoRail.Framework.Controllers.Effects2")]
\r
15 [Resource("EffectsFat", "Castle.MonoRail.Framework.Controllers.EffectsFat")]
\r
16 [Resource("Validation", "Castle.MonoRail.Framework.Controllers.Validation")]
\r
17 public sealed class FilesController : Controller
\r
19 public FilesController()
\r
23 private string GetResourceValue(string resName, string resKey)
\r
25 return (string)(Resources[resName])[resKey];
\r
28 private void RenderFile(string resourceName, string resourceKey)
\r
30 RenderText(GetResourceValue(resourceName, resourceKey));
\r
33 public void AjaxScripts()
\r
35 RenderFile("Ajax", "jsfunctions");
\r
42 You can use the LocalizationFilter attribute on a class level to specify
\r
43 how MonoRail should decide about the language:
\r
47 namespace Yournamespace
\r
49 [LocalizationFilter( RequestStore.Session, "key" )]
\r
50 public class AccountController : SmartDispatcherController
\r