Add a folder named "locale" to the root of your site. Create a subfolder for each culture you wish to support. For example, /locale/fr/.
In each culture-specific folder, create a text file named messages.po.
For testing purposes, enter the following lines of text in your messages.po file:
#: Translation test
msgid "Hello, world!"
msgstr "Bonjour le monde!"
Add a controller to your project which returns some text to translate.
usingSystem.Web.Mvc;namespaceI18nDemo.Controllers{publicclassDefaultController:Controller{publicActionResultIndex(){// Text inside [[[triple brackets]]] must precisely match// the msgid in your .po file.returnContent("[[[Hello, world!]]]");}}}
Run your MVC application and browse to the route corresponding to your controller action, such as [http://localhost:[yourportnumber]/default](http://localhost:%5Byourportnumber%5D/default).
Observe that the URL is changed to reflect your default culture, such as
[http://localhost:[yourportnumber]/en/default](http://localhost:%5Byourportnumber%5D/en/default).
1. Replace `/en/` in the URL with `/fr/` (or whatever culture you've selected.) The page should now display the translated version of your text.
1. Change your browser's language setting to prefer your alternate culture and browse to `/default` again. Observe that the URL is changed to reflect your alternate culture and the translated text appears.
1. In web.config, add handlers so that users cannot browse to your `locale` folder.
The benefit of this approach is that you don't have to clutter controllers and other classes with code to look up values from .resx files. You simply surround text in [[[triple brackets.]]] (The delimiter is configurable.) An HttpModule looks for a translation in your .po file to replace the delimited text. If a translation is found, the HttpModule substitutes the translation. If no translation is found, it removes the triple brackets and renders the page with the original untranslated text.
.po files are a standard format for supplying translations for applications, so there are a number of applications available for editing them. It's easy to send a .po file to a non-technical user so that they can add translations.