I have created two resource files in my project GlobalRes.ge.resx and GlobalResources.en.resx
I receive language as an input parameters . I want to know how can I read my values based on language. for example if string lang = "en" then by globalres.welcome I should see WOLCOME but if I choose lang = "ge" then globalres.welcome should be willkommen
(I have already created the welcome line in both files)
The Resource Designer will load the appropriate text based on the CurrentUICulture
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
bCancel.Text = Resource.Cancel;
In .NET 4.5 and later you can use the following properties to set the DefaultThreadCurrentCulture & DefaultThreadCurrentUICulture culture.
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
Related
I'm trying to use FileVersionInfo.GetVersionInfo() for some Windows(C) executables, such as rasapi32.dll. System redirects such requests to my language specific resources files (systemRoot\ru-Ru\rasapi32.dll.mui). If I can avoid this and get info from real executable (rasapi32.dll) with english copyright, product name and so on strings?
Setting System.Threading.Thread.CurrentThread.CurrentUICulture and System.Threading.Thread.CurrentThread.CurrentCulture to "en-US" doesn't helps. Also setting CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture to "en-US" doesnt't works too. What have I do to avoid redirection calling GetFileVersionInfo() (used to call it directley fron version.dll too) to mui files, but read original?
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new
System.Globalization.CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-US");
FileVersionInfo fileVersionInfoUS =
FileVersionInfo.GetVersionInfo("C:\\WINDOWS\\system32\\rasapi32.dll");
}
fileVersionInfoUS.FileDescription will contain "API удаленного доступа", instead of english "Remote Access API", other fields etc.
Thanks for advices.
I am trying to make my project multilingual. To do this, I created resource files for English and for other languages, for example:
langu.resx
langu.uk-UA.resx
In some of my projects, everything works fine. But some projects don't want to change the language.
With this System.Threading.Thread.CurrentThread.CurrentUICulture returns the correct culture
I tried changing the language in the program with the following code:
ResourceManager RM = new ResourceManager("PasteCurb.Properties.Lang.langu", Assembly.GetExecutingAssembly());
string day = RM.GetString("btnApplyText");
CultureInfo ci = new CultureInfo("uk-UA");
string dayrr = RM.GetString("btnApplyText",ci);
But in the variable dayrr, I get the value in English, instead of Ukrainian.
Anyone have any ideas?
Set the culture info like below and than you can access a text string by the name:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("uk-UA");
var text = Properties.Resources.btnApplyText;
When you access resources directly by using the ResourceManager be sure that the root name of the resource file is defined correctly. By default the root name doesn't include the language identifier.
It should look like below:
var rm = new ResourceManager("PasteCurb.Properties.Resources", Assembly.GetExecutingAssembly());
string dayrr = rm.GetString("btnApplyText", new CultureInfo("uk-UA"));
For more information see CultureInfo.CurrentCulture Property
I'm trying to prepare an application with more languages available.
I prepared the simplest example to learn it, I done a lot of tentative but I'm not able to do it.
CultureInfo cul = new CultureInfo("de-De");
Resources.Culture = new System.Globalization.CultureInfo("de-De");
label1.Text = TestLanguages.Properties.Resources.Saluto;
In my application I have two resources different resources , one for Italian language, one for German.
Italian Resource : Saluto -> Ciao
German Resource : Saluto -> Hallo
But I can't use the German one. How can I do it?
You have to change the UI culture of the currently executing thread.
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-De");
label1.Text = TestLanguages.Properties.Resources.Saluto;
See the documentation for Thread.CurrentUICulture
Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run time.
I need to get localized string resources before run (C# Winforms). I have custom control of button with printing text on event OnPaint. I can set culture for set location before running in the constractor of custom control and see erea for text in designer:
var culture = new CultureInfo("de-DE");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
But when I try to get string resource before running I get neutral string resource instead of the German:
ResourceManager p = new ResourceManager("myProject.Properties.Resources",
Assembly.GetExecutingAssembly());
Text = p.GetString(ResourceNameForText, new CultureInfo("de-DE"));
How can I get the German string resurce in designer before running?
We have found a solution. We have created an open property in custom control, which calls stream reading and parsing method from Resources.de-DE.resx during design-time mode only.
Language is not getting changed when we are giving specific culture like "fr-FR" through Resource File.please help me out of it if any one knows ,Thanks in advance.
CultureInfo cinfo = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentCulture = cinfo;
Thread.CurrentThread.CurrentUICulture = cinfo;
The below code indicate that accessing the value through resource1 file according to the culture .
_inboxpage.Text = Resource1.Ready;
The resource files need to have a special naming convention to work transparently with different culture information.
You create a separate resource file for each language that you want to support or for a language and culture. Have one separate neutral resource file for the application to fall back upon in case the required key/value pair is not found.
ex:
Resources.resx //neutral resource file
Resources.fr.resx //french specific file
Resources.fr-FR.resx //French language for France
and so on.
You can get more details here:http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
Finally i got a solution that while doing Localization in Plugin Application we need to copy that culture folders like "fr-FR" to corresponding Main Application then it will works fine.