5

I'm following this tutorial that was given as answer in this question, however I'm stuck at displaying the resource.

Just like in tutorial I've created two files

App_GlobalResources
   /Global.en.resx
   /Global.ru.resx

I've made data annotation class that works and adds a cookie with no errors, it means it injects the local data into current thread properly. When I try to output resource it cannot find it.

I've tried to output it like this and none of these works:

@Global.HomeHello
@Global.en.HomeHello
@Resources.Global.Homhello
// The name 'Resources/Global/etc...' does not exist in the current context

Also, in this tutorial site I see no logic that will inject the proper resource file, how it can do something like (in tutorial) @Global.HomeHello and it will know that if url is /en/ he needs to use Global.en.resx

Please help, first time using resources and implementing multiple languages, feels 100 times more harder and confusing than using *.yml files in other frameworks/languages...

Community
  • 1
  • 1
Stan
  • 25,744
  • 53
  • 164
  • 242

1 Answers1

12

You took a bad example to follow I guess. Please look into the following article:

Resource Files and ASP.NET MVC Projects

Don't forget to change Custom Tool to PublicResXFileCodeGenerator and Custom Tool Namespace to Resources.

Hope this helps & good luck.

Display Name
  • 4,672
  • 1
  • 33
  • 43
  • Okey, now I have two `*.resx` files in my `Languages` directory, both have class `Languages` and I can call `@Languages.English.HomeHello`. But now the big problem is, how can I do something like `@Languages.HomeHello` and it will pick correct `*.resx` file depending on my locale? – Stan Sep 28 '12 at 13:59