Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: How to bind the text of a winforms button to a resource

We have a resource file with lots of translated strings used various places in our application. Is there a better way for binding for example the text of a button to a certain string?

Currently we are usually just doing something like this in the constructor, in a Load event handler or in a method called by one of those:

someButton.Text = CommonTexts.SomeString;
someMenuItem.Text = CommonTexts.SomeOtherString;

Is there a better way to do it? Maybe in the designer? Or is this the recommended way of doing it?


Just to let you know how we do the actual translation: We have one Class Library project which only contains resx files. The main resx files are written in english (of course). We then open up those base resx files in an application called ResEx where we (or someone else) does the translation to other languages. When compiled Visual Studio automatically creates assemblies for each language which are used automatically depending on the current culture set. This works pretty well, so I don't really need info on how to do the translation and such (although I am always curious to improvements of course). What I am asking is if there is a better way for getting those translated strings from the resource assembly and into all the various Text properties.

like image 848
Svish Avatar asked Aug 24 '09 13:08

Svish


People also ask

Bahasa C digunakan untuk apa?

Meskipun C dibuat untuk memprogram sistem dan jaringan komputer namun bahasa ini juga sering digunakan dalam mengembangkan software aplikasi. C juga banyak dipakai oleh berbagai jenis platform sistem operasi dan arsitektur komputer, bahkan terdapat beberepa compiler yang sangat populer telah tersedia.

C dalam Latin berapa?

C adalah huruf ketiga dalam alfabet Latin. Dalam bahasa Indonesia, huruf ini disebut ce (dibaca [tʃe]).

Bahasa C dibuat pertama kali oleh siapa dan tahun berapa?

Bahasa pemrograman C ini dikembangkan antara tahun 1969 – 1972 oleh Dennis Ritchie. Yang kemudian dipakai untuk menulis ulang sistem operasi UNIX. Selain untuk mengembangkan UNIX, bahasa C juga dirilis sebagai bahasa pemrograman umum.


1 Answers

I understand, it's an old question, but still, I had the same issue (VS 2010), and one of the first links in google is this topic.

In order to move all the texts to forms resource file - you need to set the winform Localizable property to True. And that's it. :) (c) Cap. O.

like image 143
Vital Avatar answered Nov 01 '22 14:11

Vital