Localization of Resource Files

how to use the resource.designer.cs code

Page 1 of 1

1 Replies - 5294 Views - Last Post: 28 May 2009 - 11:54 AM Rate Topic: -----

#1 redivider  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 28-May 08

Localization of Resource Files

Posted 29 April 2009 - 09:10 AM

I'm trying to implement an multi-lingual GUI for a winforms application.
I have all the GUI string in one Resource file which i've already had translated.

The way I'd like to implement it is to use the Resource.designer.cs code to call the strings.
This would allow me to use intelisense to find the strings. Currently my code can do this with the english resource file. I can call Resources.ErrorApplicationerror to get the string.

The problem is that since the classes generated in the designer class do no inherit from a common source I can't change the Reources variable to point to any of the other languages.
I would try to make an interface that implements all the strings, but the Resources class members are implemented as statics so its not allowed.

Any ideas? I feel i must be missing something.

Resources.Designer.cs implementation:
	   
	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
	[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
	[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
	public class Resources {
	...
	/// <summary>
		///   Looks up a localized string similar to Application Error Occurred.
		/// </summary>
		public static string ErrorApplicationerror {
			get {
				return ResourceManager.GetString("ErrorApplicationerror", resourceCulture);
			}
		}


Is This A Good Question/Topic? 0
  • +

Replies To: Localization of Resource Files

#2 redivider  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 28-May 08

Re: Localization of Resource Files

Posted 28 May 2009 - 11:54 AM

Found It.
The resource class has a property called culture, which can be set by
Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES", true);
Resources.Culture = CultureInfo.CurrentCulture; 

The resource class can then do all the marshalling to the correct resource file.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1