Reputation: 4383
I need to show the Exception message for a WCF service in a localized language, that is different from English. For example, if I run this instruction anywhere in my code:
throw new ArgumentNullException(name, "El parámetro es obligatorio.");
The result is that the text "El parámetro es obligatorio. Parameter name: XXXX" is shown.
I need "Parameter name" text to be translated into Spanish. I think I need to modify thread culture, but I am not sure how to do this since this is a WCF service.
Upvotes: 0
Views: 211
Reputation: 2397
If the language depends on the particular client, I'd create an overload of the functions of the service with an additional parameter for the language, and set both CurrentCulture and CurrentUICulture.
If the language does not depend on the client (i.e. same language for a whole site), set it somewhen during start. Note that a new thread inherits the language from Windows, not from the parent thread, hence you have to set it again for every freshly created thread (a newer version of the .Net framework allows to overwrite that behavior).
In any case, make sure that the language pack for the framework is installed.
Upvotes: 1