Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can language localisations be automatically reverse engineered from .resx files?

I'm working with an MVC 4 app that was originally created with the intention of possibly requiring language localisation so there's a heavy use of .resx files and corresponding embedding of references throughout the project. As it turns out, the app will only ever be used by English speaking audiences and indeed no other languages were ever loaded in. What we've got now is an overhead every time we need to put text on a page and increasing inconsistency as English language is hard-coded into places which can't directly access the resource files such as .js files and reference data in the DB.

Short of a lot of copying and pasting, is there any automated way to extract the English language values from the resource files and replace their references in the views? In a perfect world there'd be a tool to do this and certainly it's conceptually scriptable, does anything like this exist already?

like image 605
Troy Hunt Avatar asked Mar 08 '13 01:03

Troy Hunt


2 Answers

You will have to script it. I have done similar stuff with the O2 Platform AST manipulation Mono.Cecil and mono Cecil APIs.

If you give me a small project with the use can you need (a resx file and an MVC view) I can show you a code snippet example

like image 85
Dinis Cruz Avatar answered Sep 30 '22 04:09

Dinis Cruz


I haven't seen anything that would take care of this. My first thought is because of the localization issues that could be presented in most "out of the box" solution.

This maybe far fetched, but giving it a shot. Could you write a C# app that would load the assembly that holds the resource file, then loop through every file in the project and replace the resource keys with the values?

As you said, it is possible to be scripted, and this seems like the easiest yet crudest way to complete the task in my mind. Depending on the number of resources you're talking about, obviously it maybe easier and safer to copy/paste.

like image 37
Steven V Avatar answered Sep 30 '22 03:09

Steven V