Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I have a project, (C#, wpf, .net 3) and uses the strings. concept to localize
my application for different languages.

How do I set the button text to the correct language ?

It does not work with
myButton.SetText(strings.hello)

Do I do it in the xml file to for the window or can/should I do in the C# code ?


Regards
Posted
Updated 4-Aug-11 20:35pm
v2

In Properties of your project add Resource files for different languages and name them according to the Language code like for Brazilian-Portuguse(name your resource file something like StringResource.pt-BR.resx). Now in text property of the Button control write something like myButton.Content= Properties.StringResource.IDOfTheString. According to the Syatem Language it will take care. Check <a href="http://www.codeproject.com/KB/dotnet/Localization.aspx"/> for getting more idea on Localization Issues.
 
Share this answer
 
v4
Comments
Sergey Alexandrovich Kryukov 5-Aug-11 2:54am    
Right, a 5.
--SA
Bizarre. The first google hit[^] was an article on this very site. I know some countries don't have google, but you obviously have code project. You didn't think to search the site for articles ?
 
Share this answer
 
Why don't you save the text what you want to show in button into a resource file, and while the program star, identify which language is default(this is another subject), then select the right resource file.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Aug-11 2:53am    
This is right idea but all operations you described after creation of resource file are not needed, because this code is already a part of .NET. Read about satellite assemblies. If such assembly if written and named correctly, .NET auto-select it based on thread and thread-UI culture. Please learn it yourself before advising others.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900