Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get CultureName from the English language name
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Get CultureName from the English language name
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01621706
Message ID:
01621706
Vues:
46
Hi everybody,

For our middleware dll application we want to be able to change the interface (strings that are returned by methods in this dll) into different language. We would pass the language name from another application, say, English, French, German, etc.

My plan is to use Resources as we're using in our Web application. So, for the strings I would just use the Labels.myString and I hope that the correct resource will be automatically selected based on the current culture.

I found the following page https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.defaultthreadcurrentculture.aspx?f=255&MSPPError=-2147217396 and this is the solution I plan to implement to set the culture for the entire application. I suppose I can switch it this way, right?

So, few questions:

1. Am I right in my assumption that using the method from this page to set globally culture info is all I need to change the language?

2. How would I know culture name if I only get the English name of the language?

Update. This looks like what I needed (from http://stackoverflow.com/questions/2432813/how-to-translate-cultureinfo-language-names)
 public CultureInfo GetCultureInfo(string EnglishName)
    {
        foreach (CultureInfo info in CultureInfo.GetCultures(CultureTypes.AllCultures))
        {
            if (info.EnglishName == EnglishName)
                return new CultureInfo(info.Name);
        }

        return null;
    }
Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform