By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 2,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

Problem in Accessing Resource Manager

P: n/a
Hi,
I am developing a windows application which should support different
language for this I am using "Resource Manager" default in .net
framework.

Here I am developing dll for Resource because there are different
application which can access one dll avoid duplications.

Resource File Name :
Resources/MyAppResource.de.resx
Resources/MyAppResource.ja.resx
Resources/MyAppResource.en.resx
Resources/MyAppResource.fr.resx

But here I am facing a big problem.
I created Resource files for four languages as above,
1] Here It is allowing me to use only two letter only if I use ja-JP
the resource manager is not loading the resource set.
2] I am able to access resource strings through "ResourceSet" objects
only, If I create Resource Manager for each language try to access.

3] I am able to access only through the ResourceSet only.


# # # # # # # # # # #

private void button2_Click(object sender, System.EventArgs e)
{
CultureInfo m_EnglishCulture = new CultureInfo("en-US");
CultureInfo m_JapanishCulture = new CultureInfo("ja-JP");
CultureInfo m_FranceCulture = new CultureInfo("fr-CA");
CultureInfo m_DeutchCulture = new CultureInfo("de-AT");

textBox1.Text += Environment.NewLine ;

textBox1.Text += GetString("frmbtn",m_EnglishCulture ) +
Environment.NewLine;
textBox1.Text += GetString("frmbtn", m_JapanishCulture)+
Environment.NewLine;
textBox1.Text += GetString("frmbtn", m_FranceCulture) +
Environment.NewLine;
textBox1.Text += GetString("frmbtn",m_DeutchCulture ) +
Environment.NewLine;

}

private Hashtable m_htResource = new Hashtable();
ResourceManager rm ;

private string GetString(string Key, CultureInfo cinfo)
{
string strCulutre = cinfo.TwoLetterISOLanguageName;;
string strReturnValue ="";
if( m_htResource.Contains(strCulutre) )
{
strReturnValue = ((ResourceSet)
m_htResource[strCulutre]).GetString(Key, true);
//strReturnValue =
((ResourceManager)m_htResource[strCulutre]).GetString(key, cinfo); //
Resourcemanger
}
return strReturnValue;
}
private void LoadAllResources()
{
if( rm == null)
{
rm = new ResourceManager("MyAppResource.Resources.MyAppReso urce",
Assembly.GetExecutingAssembly());
}
string[] strAssemblies = {"en-US", "ja-JP", "de-AT", "fr-CA"};
CultureInfo c ;
foreach(string s in strAssemblies)
{
c = new CultureInfo(s);
ResourceSet rSet = rm.GetResourceSet(c, true,true);
m_htResource.Add(s, rSet); //en-US

if( s.Split('-').Length 1)
m_htResource.Add(s.Split('-')[0], rSet); // en

//ResourceManager rm1 = new
ResourceManager("MyAppResource.Resources.MyAppReso urce",
Assembly.GetExecutingAssembly());
m_htResource.Add(s, rm1);
}
}

private void TestForm_Load(object sender, System.EventArgs e)
{
LoadAllResources();
}

Jul 25 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.