3

I need to translate a website made in English into Spanish (multilangauge support is not necessary). The website is going to be used only in Spanish so there is no need to bother implementing 'resources' or localisations.

The text needing translation is in two locations:

  • Static within HTML pages
  • In code behind, such as error messages etc.

The rest of the data (DB, XML, etc) have already been sorted out.

So is there any tool or a method which is not very time consuming to extract all of the text, as mentioned above? The extracted text doesn't even need to be in a key/value pair. I'll be happy to have the extracted text in a simple format, each separted by a new line.

It would be nice for a way to replace the translated text back into its original location. But, this is not a necessity. I'll be happy to have everything only extracted.

Please try to stick to answer the question as is (e.g. solutions such as using Google to display a translated version of the site don't really help!).

Thank you so much in advance.

(this is an ASP.Net website with codebehind written in C#)

shadowf
  • 1,176
  • 1
  • 12
  • 15
  • Using resources file (.resx file) you can achieve this. refer similar article http://satindersinght.blogspot.in/search/label/How%20to%20create%20website%20for%20mulilanguages%20supports – Satinder singh Apr 19 '13 at 07:49
  • Satinder, thanks for your comment. However, if you read my question again, I do not need a multiple language platform. **I only need to extract all the strings site-wide.** – shadowf Apr 19 '13 at 08:24
  • 1
    Try this solution. You don't actually have to implement the local resources, but you could use it to locate all your hardcoded strings: http://stackoverflow.com/questions/2490974/find-all-source-hardcoded-strings – Yeronimo Apr 19 '13 at 09:07
  • hmmm, thanks very much @Yeronimo, it sounds like exactly what I what! I don't have ReSharper on my machine tho. So I've got to give this a go later on. Thanks again! – shadowf Apr 19 '13 at 10:13
  • There is a fully function 30 day trial available :) – Yeronimo Apr 19 '13 at 10:16
  • Thanks very much. You're an absolute star! :-) – shadowf Apr 26 '13 at 09:31

1 Answers1

0

Despite your current requirement that the website is only translated into Spanish, you can never know your future requirements for other languages - the default ASP.NET key/value pair resource file solution makes a lot of sense for this and other reasons.

Using local resource files (which are effectively XML in a pre-set schema) on the server avoids costly round trips to the database every time a page loads (although this could be mitigated by output caching) and makes it very easy to send your phrases for translation - all of the phrases are in one place, in the same file. There are a range of tools available to work with them as you might expect given the ubiquity of .NET. It is even possible to translate a resource file using Bing to give your translator a head start.

Using a key rather than matching string literals makes a lot of sense given the issues of the same string being used in multiple contexts (where it may be desirable or necessary to translate the text in different ways for each context - words don't always share the same possible meanings in different languages) or issues like capitalisation, where you may want the same string with different capitalisation (although this should not be an insurmountable problem programmatically).

Lastly using the built in localisation API in ASP.NET makes it trivial to change the language and UI (date formats for example) based on the locale the user has chosen on their computer - and is sent in the request headers by the browser. A Spanish speaking visitor turns up at your site, and it is already in Spanish - no need to hunt for the control to change language based on flags or a drop down list. This can be manually set or overridden by you if required, and of course only applies if your site has a resources file appropriate for the locale, but is an incredibly powerful feature available out of the box.

If you are using ASP.NET Web Forms then I would definitely second the recommendation for using Resharper to extract your strings to a named key for you, but you should be aware that it cannot yet do this with Razor views if you are using ASP.NET MVC or Web Pages - although it will still offer to move strings from the model in the case of MVC (and indeed encourage you to do so).

Lastly, please be aware that localisation is about more than language - your users may use different formatting for dates, numbers, telephone numbers or even different text direction in some cases. This may not apply in your project but is certainly something to be aware of.

pwdst
  • 13,909
  • 3
  • 34
  • 50
  • Thank you very much for your answer. A thorough overview of localization indeed. I do agree with you and I do use localization in various projects. This particular project for which I asked this question, however, is meant to be used in Spanish (and only Spanish). The problem I had with it was that I developed the website in English as I am not a native Spanish speaker and the English text was supposed to be translated into Spanish by a native speaker once the project was finished. The problem was to extract all the text from the frondend and code-behind codes as I mentioned in the question. – shadowf Nov 02 '13 at 05:12
  • As mentioned in the answer and previously by other comments ReSharper is the easiest way to do this. You can download a thirty day free trial, although I'd suggest a personal license is well worthwhile. The only problem with this approach is that English would become the default language of the site, unless the user's browser identifies Spanish locale. I'd imagine you can rename the default file with the en-US (or en-GB) postfix and remove the es-ES postfix from the Spanish file, or only deploy the (postfix removed) Spanish file to live. Keep in mind potential string value length differences. – pwdst Nov 03 '13 at 12:35
  • Thank you for your answer and comment. For future reference if anyone is looking for a solution to the same problem, ReSharper seems like it can do what I was looking for - however I have actually not tried it yet, so I can't comment on its efficency or ease-of-use. – shadowf Nov 03 '13 at 16:17