-
Notifications
You must be signed in to change notification settings - Fork 4
Home
itechnology edited this page Dec 5, 2012
·
11 revisions
#TOC
- Basic Usage
- Advance Usage
- Configuration Options
###Inside a non website project
- Drop T4ResX.tt inside any project containing RESX files, open it, and do a CTRL+S to save it. This will trigger the T4 code generation and output a strongly typed code in the form of T4ResX.cs. Now simply compile the project, and you now have a strongly typed assembly that you can use inside other projects.
###Inside web pages Once your localized assembly generated and compiled, include a reference to it in you website project. If you are not using a separate assembly to localize your files, simply drop T4ResX.tt in the root of your website project, double click to open it, do a CTRL+S to save it. Now your localized code is generated, and simply rebuild your site.
Then:
- Simply start writing code like
@Resources.User.Pseudoor<%= Resources.User.Pseudo %>depending on whether you are using MVC or ASP.NET
###Localized JavaScript Once your localized assembly generated and compiled, include a reference to it in you website project.
Then :
- We first need to include a small helper method inside our project to be able to return JSON serialized content.
- We declare our method in our page or controller that returns the JSON generated above in the form of raw JavaScript.
- Include a
<script src="/MyController/MyMethod?ns=NameSpaceToLoad"></script>inside whatever page you want to use localized JavaScript in.
#Advanced Usage (docs in progress....)
- Formatting Variables
- Doing things like
Field {0}, must be different to field {1} - This for example is how MVC formats error messages
- Doing things like
- Replacement Variables
- Doing things like
Hello {0}, welcome to {BRAND}- This allows you to store replacement variables for things like, DOMAIN, BRAND, PRODUCTNAME inside a database or a configuration file, and have those variables replaced on the fly
- Doing things like
- Constants
- Pulling parts out of the assembly in the form of
Dictionary<string, Dictionary<string, string>>- This is how we are able to store text in RESX files and the extract parts of it into localized JavaScript files.