locked
Localizing messages built at run-rime RRS feed

  • Question

  • User206383436 posted

    We are developing a web application in Spanish language but we will need at least the English language too. I have been reading about the localization support in Visual Studio 2010 and everything is good, every ASP.NET control's property (like text and tooltip) in our app can be translated and we can accomplish our goal partially. I say partially because the controls in our app are not the only parts of the project that contain text to be translated because there are application messages that are sent to the user which are generated at run time. For example, every "Try..Catch..Finally" block builds a message in the "Catch" portion to inform the user that something happended. What I mean with this is that there are messages built at run time within the C# code. Another example is validation, we do not always use ASP.NET validation controls to validate input data, sometimes it is performed in the C# server-side code and sometimes in Javascript client-side code and here is where the message is formed. How can we approach this situation? Is there any localization method available for a case like this?

    Respectfully,
    Jorge Maldonado 

    Tuesday, December 13, 2011 12:03 PM

All replies

  • User-519136805 posted

    Hi Jorge, For that you can use Globalization. you need to create Global Resourse files and store the messages that is global to the application and you ca fetch global resourse text runtime and assign it the appropriate control/variable as well. check this out for more information.

    Hope this will help !!!

    Friday, December 16, 2011 10:10 AM
  • User206383436 posted

    Hi Jorge, For that you can use Globalization. you need to create Global Resourse files and store the messages that is global to the application and you ca fetch global resourse text runtime and assign it the appropriate control/variable as well. check this out for more information.

    Hope this will help !!!

    When using implicit localization, for example, ASP.NET automatically knows which resource file to use based on the current language/culture. This does not happen when getting resource file key/values programmatically. Am I correct?

    If I have several global resource files, one for each language, how do I know which resource file to use? Do I need to detect the current language/culture and use the appropriate file?

    With respect,

    Jorge Maldonado 

    Tuesday, December 27, 2011 2:40 PM
  • User-519136805 posted

    Hi Jorge, You are right, if you want to access global resource , thn you can check for culture of the site and fetch file accordingly. if you have specified proper naming as per culture settings, than dotnet will automatically fetch the appropriate text based on cultureinfo. please also check overload available with GetGlobalResourceObject method.

    Hope this will help !!!

     

    Monday, January 30, 2012 1:54 AM