Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ResourceManager and not supported platform

I use ResourceManager for UI localization of my WinCE 5 software. I have some resource files with text strings on different languages

Resourse.resx
Resourse.de-DE.resx
Resourse.ru-RU.resx

When I want to display UI in English I call:

Resourse.Culture = new CultureInfo("en-US");
label1.Text = Resourse.LabelText;

in German:

Resourse.Culture = new CultureInfo("de-DE");
label1.Text = Resourse.LabelText;

in Russian:

Resourse.Culture = new CultureInfo("ru-RU");
label1.Text = Resourse.LabelText;

but here I get PlatformNotSupportedException.

I know that my WinCE does not contain Russian and I cannot modify OS to appened this, so my question is how I can say to ResourceManger to use Resourse.ru-RU.resx when I set Culture = new CultureInfo("ru-RU") ?

like image 758
wince Avatar asked Nov 19 '25 10:11

wince


2 Answers

The answer Jonathan provided is the exact work around I had to do to get my device to show Simplified Chinese. I used "en-ZW" English(Zimbabwe). This worked on 3 different devices all running a different OS (CE5, CE6, and WEH/WM 6.5.3)

If the base Tahoma font doesn't contain everything you need, as in my case, you also need to put the font on the device and make some additional registry changes to enable font linking. It's not very complex, only a couple of registry entries.

This MSDN link provides the information for the Chinese fonts but it would be used the same way for any other font set. http://msdn.microsoft.com/en-us/library/ms901082.aspx

The more generic MSDN articles on font linking can be found here: http://msdn.microsoft.com/en-us/library/ms901098.aspx

Other than this the only other option I was able to determine was to roll your own translation resource class.

like image 191
ScorpionJL Avatar answered Nov 22 '25 00:11

ScorpionJL


The following is a rather HACKED workaround, but it will solve the PlatformNotSupportedException issue. I would also recommend doing this only as a last resort. Please note that I have only tested this on WinCE 6.0.

If the culture you are attempting to implement is not supported by WinCE 6.0, simply re-label it as a different culture. For example, rather than marking the Russian culture as "ru-RU" (as above), you could re-name it as "eu-ES" (Basque). Provided that the font being used supports the Cyrillic character set, the values should display as you have written them.

Note: You MUST also rename your resource file to match the target culture you are substituting. If you are using "eu-ES" in place of "ru-RU", you must rename your "Resourse.ru-RU.resx" to "Resourse.eu-ES.resx".

What you lose: Any native support provided by the target culture (Russian in this case), (e.g. correctly formatted currencies, dates, etc), since these would now be being drawn from the work-around target culture (Basque in this case). Note that this should only be a problem in your application if you are formatting your strings via culture (i.e. stringFormat({some CultureInfo.GetCurrentCulture}, {additional formatting}, {some numerical value})).

like image 30
MemoryServed Avatar answered Nov 22 '25 01:11

MemoryServed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!