views:

33

answers:

2

The company for which I work for has built a large ASP.NET MVC application last year and it wasn't prepared to support Localization to begin with as the main goal of this application was to serve portuguese clients. But as the application took greater proportions, the demands were that it should support other languages, like english for instance. I was asked to implement localization for it. I did some research about how resource files are added. But I need a sort of automated localization, maybe a way of having resource files automatically generated for each view, getting the content that needs to be localized. I've already made up an excel file with every string in the application and its translation to the languages required. How could I go about this?

+1  A: 

It is possible to have what you're now stuck with in Excel exported as the appropriate .resx files. There are many ways to do this, depending on your version of Excel. If you're up for (more) manual labor, you can just create the required .resx files in Visual Studio and do some copy and pasting.

Having .resx files automatically generated from a view requires some kind of tooling. There are Visual Studio add-ins that will do this for you; Resource Refactoring Tool is one of them (I think ReSharper has similar capabilities too). Extracting texts to resources automatically would be a bit impractical and would lead to resource keys that are automatically generated and not very intelligible. Doing this manually will yield the best result.

When you're extracting text fragments to resources, I can recommend that you put all .resx files into a separate assembly so the resource texts can be used across several assemblies, in error messages, exceptions, etc. This requires them to be global, of course.

asbjornu
Well, I had to copy the strings to an excel file because some of the translations were to be made by the client himself because he wanted to add some context to them in different languages. The file would go to them before actually reaching us with the actual translations.
Hallaghan
I see. Since `.resx` files and Excel both have a spreadsheet-like editing interface, you can actually select the rows you want to copy from Excel and paste them into the resource editor in Visual Studio. The only thing you need to make sure of is that you don't have data in more than 3 columns ("Name", "Value" and "Comment") in Excel.
asbjornu
I feel this will be a very painful task already... Well, copying 2400 strings from the application to the excel file was already painful enough, but here comes hell! Thanks for the advises.
Hallaghan
As long as you make sure the Excel spreadsheet has 3 columns matching the 3 columns in the resource editor, it's just a matter of creating the `.resx` files, selecting the rows you want to copy in Excel, copying them, then pasting them into the resource editor. While 2400 resource strings are a lot, I foresee the Excel-to-resx copying to take a lot less work than application-to-Excel. Good luck! :)
asbjornu
A: 

I think this tool could help you. There seems also to be another one, but the page is currently offline.

Kitto
The tools both of you have pointed to me are quite good but they would only work for the controllers. My main problem are the views. Do you got any suggestions for that?
Hallaghan
I think ReSharper's resource extraction supports extracting from any type of file. It costs money, but it's a massive tool that helps with way more than ust resource extraction: http://www.jetbrains.com/resharper/features/code_refactoring.html#Move_String_to_Resource
asbjornu