c# – How to use languages ​​that are not officially supported by "windows phone"?

Question:

Good day, Hashcode.

As far as I understand, now in WP7, the application language by default adjusts to the language in the settings (region + language -> interface language). There are quite a few articles on this topic, and everything is quite simple. But there is a problem. WP7 does not support so many languages, and for example I have a need to use languages ​​that are not included in the list of supported ones.

I tried to install the language directly:

    Thread.CurrentThread.CurrentCulture = new CultureInfo("ыы-ЫЫ");
    // ыы-ЫЫ - аббревиатура никому не известного языка
    Thread.CurrentThread.CurrentUICulture =    Thread.CurrentThread.CurrentCulture;

However, this did not work out, since the program swears into unknown languages. With the famous, everything goes away.

How can such languages ​​be used? Anyone have any ideas?


[updated 09/10/2012]

So, a more relevant question:

I suddenly noticed that after changing the language, a reboot of the OS is required. Is it okay? And is it possible to somehow get around this garbage?

Answer:

A solution is described here:

Localization with an unsupported language

At first glance, it works. As I check my version, I will unsubscribe about the results.


I did it, it really works, although there are quite a few pitfalls. As time will be – I will write down the decision in detail.


So:

Opportunities for a shot in the leg (pay attention to those who first wrote in the style recommended by Microsoft (like me), and then will have to implement a new language. All calls to resources will have to be rewritten. It's sad. Let's go):

In the LocalizedResources.cs class, the path to the resource manager is described in the style:

_rman = new global::System.Resources.ResourceManager("AppName.Folder.ResourcesApp", typeof(ResourcesApp).Assembly);

for famous languages

where:

AppName – the name of the application

Folder – the folder that contains the resources. I had it in the Resources folder. If at the root – respectively, we do not write anything.

ResourcesApp is what our files are called for known languages. In the example, it is one and called Resource (for English). Those. for English it will be Resource.resx or Resource.en-US.resx or Resource.en-UK.resx, for Russian Resource.ru-RU.resx, etc. The postfix (a.k.a ru-RU) does not matter, the desired language will then be selected through the SwitchCulture method.

for unknowns, the overloaded SwitchCulture method is used accordingly :

public void SwitchCulture(string UnsupportedCulture)
        {
            _rman = new global::System.Resources.ResourceManager("App.Resources.XXX" + UnsupportedCulture, typeof(ResourcesApp).Assembly);
        }

where XXX is the complete name of the resource file for the unknown language.

In the example, these files are named Resource_Klingon.resx and Resource_Vulcan.resx.

// there should be an underline between words, for some reason it is not displayed

I had ResourcesApp.LanguageName.resx respectively

Those. in the example, the path looked like "PhoneApp1.Resource_" , in my case "App.Resources.ResourcesApp."

The Get method is used to access resources. Accordingly, all calls are in the style:

Resources.resourceName

will have to be replaced with

LocalizedResources.Resources.Get("resourceName")

The situation is similar with binding via Binding . Instead of calls like:

"{Binding Path=LocalizedResources.someName, Source={StaticResource LocalizedStrings}}"

are used

{"Binding Source={StaticResource LocalizedStrings}, Converter={StaticResource LocalizedStrings}, ConverterParameter=someName}"
Scroll to Top
AllEscort