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.d e.resx
Resources/MyAppResource.j a.resx
Resources/MyAppResource.e n.resx
Resources/MyAppResource.f r.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 "ResourceSe t" 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(o bject sender, System.EventArg s e)
{
CultureInfo m_EnglishCultur e = new CultureInfo("en-US");
CultureInfo m_JapanishCultu re = new CultureInfo("ja-JP");
CultureInfo m_FranceCulture = new CultureInfo("fr-CA");
CultureInfo m_DeutchCulture = new CultureInfo("de-AT");
textBox1.Text += Environment.New Line ;
textBox1.Text += GetString("frmb tn",m_EnglishCu lture ) +
Environment.New Line;
textBox1.Text += GetString("frmb tn", m_JapanishCultu re)+
Environment.New Line;
textBox1.Text += GetString("frmb tn", m_FranceCulture ) +
Environment.New Line;
textBox1.Text += GetString("frmb tn",m_DeutchCul ture ) +
Environment.New Line;
}
private Hashtable m_htResource = new Hashtable();
ResourceManager rm ;
private string GetString(strin g Key, CultureInfo cinfo)
{
string strCulutre = cinfo.TwoLetter ISOLanguageName ;;
string strReturnValue ="";
if( m_htResource.Co ntains(strCulut re) )
{
strReturnValue = ((ResourceSet)
m_htResource[strCulutre]).GetString(Key , true);
//strReturnValue =
((ResourceManag er)m_htResource[strCulutre]).GetString(key , cinfo); //
Resourcemanger
}
return strReturnValue;
}
private void LoadAllResource s()
{
if( rm == null)
{
rm = new ResourceManager ("MyAppResource .Resources.MyAp pResource",
Assembly.GetExe cutingAssembly( ));
}
string[] strAssemblies = {"en-US", "ja-JP", "de-AT", "fr-CA"};
CultureInfo c ;
foreach(string s in strAssemblies)
{
c = new CultureInfo(s);
ResourceSet rSet = rm.GetResourceS et(c, true,true);
m_htResource.Ad d(s, rSet); //en-US
if( s.Split('-').Length 1)
m_htResource.Ad d(s.Split('-')[0], rSet); // en
//ResourceManager rm1 = new
ResourceManager ("MyAppResource .Resources.MyAp pResource",
Assembly.GetExe cutingAssembly( ));
m_htResource.Ad d(s, rm1);
}
}
private void TestForm_Load(o bject sender, System.EventArg s e)
{
LoadAllResource s();
}
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.d e.resx
Resources/MyAppResource.j a.resx
Resources/MyAppResource.e n.resx
Resources/MyAppResource.f r.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 "ResourceSe t" 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(o bject sender, System.EventArg s e)
{
CultureInfo m_EnglishCultur e = new CultureInfo("en-US");
CultureInfo m_JapanishCultu re = new CultureInfo("ja-JP");
CultureInfo m_FranceCulture = new CultureInfo("fr-CA");
CultureInfo m_DeutchCulture = new CultureInfo("de-AT");
textBox1.Text += Environment.New Line ;
textBox1.Text += GetString("frmb tn",m_EnglishCu lture ) +
Environment.New Line;
textBox1.Text += GetString("frmb tn", m_JapanishCultu re)+
Environment.New Line;
textBox1.Text += GetString("frmb tn", m_FranceCulture ) +
Environment.New Line;
textBox1.Text += GetString("frmb tn",m_DeutchCul ture ) +
Environment.New Line;
}
private Hashtable m_htResource = new Hashtable();
ResourceManager rm ;
private string GetString(strin g Key, CultureInfo cinfo)
{
string strCulutre = cinfo.TwoLetter ISOLanguageName ;;
string strReturnValue ="";
if( m_htResource.Co ntains(strCulut re) )
{
strReturnValue = ((ResourceSet)
m_htResource[strCulutre]).GetString(Key , true);
//strReturnValue =
((ResourceManag er)m_htResource[strCulutre]).GetString(key , cinfo); //
Resourcemanger
}
return strReturnValue;
}
private void LoadAllResource s()
{
if( rm == null)
{
rm = new ResourceManager ("MyAppResource .Resources.MyAp pResource",
Assembly.GetExe cutingAssembly( ));
}
string[] strAssemblies = {"en-US", "ja-JP", "de-AT", "fr-CA"};
CultureInfo c ;
foreach(string s in strAssemblies)
{
c = new CultureInfo(s);
ResourceSet rSet = rm.GetResourceS et(c, true,true);
m_htResource.Ad d(s, rSet); //en-US
if( s.Split('-').Length 1)
m_htResource.Ad d(s.Split('-')[0], rSet); // en
//ResourceManager rm1 = new
ResourceManager ("MyAppResource .Resources.MyAp pResource",
Assembly.GetExe cutingAssembly( ));
m_htResource.Ad d(s, rm1);
}
}
private void TestForm_Load(o bject sender, System.EventArg s e)
{
LoadAllResource s();
}