User interface localization

I am working on a localization project and when I change the language the UI breaks because some of the translations are big. For example, let's say there is a button with the text Select All. But when localized in French, it reads "Sélectionner tout". This is more than Select All and hence the gui is affected. Is there a way to localize the gui.

+2


source to share


3 answers


since the final text for "Select All" can be converted to text of any length, which in this particular case "Select All" changes to "Sélectionner tout" and you don't want your UI to be broken, you can specify the width in% and we hope your final text has enough space.



I'm not sure if there is a way to deal with runtime width versus length, since you can count the length and give the width in pixels, it wouldn't be a good idea. so they have less text and give a percentage width.

+1


source


I suggest you create a Pseudo culture to handle this.

The pseudo-culture will contain the largest translation for the specified string among all cutltures.

For example, if you have a Resx file named strings.resx, and another culture based file might be in French strings.fr.resx, and another in Dutch, strings.nl.resx.

Then create another file called string.pseudocult.resx, pseudocult should be replaced with whatever culture you don't support, like string.az.resx

strings.resx

< data name="Select_All" xml:space="preserve">
    < value>Select All</value>
< /data>

      

strings.fr.resx



< data name="Select_All" xml:space="preserve">
    < value>Sélectionner tout</value>
< /data>

      

strings.nl.resx

< data name="Select_All" xml:space="preserve">
    < value>Alles selecteren</value>
< /data>

      

strings.az.resx

< data name="Select_All" xml:space="preserve">
    < value>Sélectionner tout</value>
< /data>

      

The value in az should be measured by finding the longest GUI-based string using translations in supported cultures, in which case the longest GUI-based translation was in French culture. This will essentially provide you with a minimum size for each control in your application, as well as discernment if you must change the translation.

Otherwise, if you want to omit this, you must keep the size of controls containing words between 5% and 300% of their original required size and more than 5% to 170% of their original size.

+1


source


Just open your interface in Visual Studio Designer and set the property Localizable

to Form

or UserControl

to true

. This step automatically adds a new file .resx

to your UI element that contains all property values. These values ​​will be applied in the first step and will take effect if a match is now found for the current crop.

Then just switch the property Language

to the language you want to support, which has its own set of text and layout. If you now make any changes to your user interface, you set another one to .resx

be added to your component and any changes you make will be written to that file.

So just create your control however you like, set the property to a Localizable

value true

, switch the property Language

to a new supported language, and tweak the gui as needed.

A more detailed article on localization can be found on MSDN .

0


source







All Articles