Creating Multilingual Application

Download Project File
Today, without any doubt, we can say that English is the key to become international. But with this dominant feature of English, what will be happen to local languages. Its very alarming. For this reason, I've tried to create a multilingual language. Just look at the snapshots bellow.
Here I've used two xml document to store text information. Prior that I've seen a multilingual application that is much more sophisticated then mine in But I can't understand the code properly. Then I decided to make one at my own hand. There are much reason for not understanding. I'm a very new guy in dot net programming. I've started my dot net programming in January 2010.

Every single piece of information is stored in XML files. I have used one XML for a language.
xml version="1.0" encoding="utf-8" ?>
  <Title text="Bilingual Calculator"/>
    <One text="1"/>
    <Two text="2"/>
    <Three text="3"/>
    <Four text="4"/>
    <Five text="5"/>
    <Six text="6"/>
    <Seven text="7"/>
    <Eight text="8"/>
    <Nine text="9"/>
    <Sqrt text="Sqrt"/>
    <Inverse text="1/X"/>
    <Exit text="Exit"/>
    <Cancel text="C"/>
    <File text="File" Submenu="Exit"/>
    <View text="View" Submenu="Standard"/>
    <About text="About" helptext="Programmed By: Ahmed All Razi
Mobile: 01712-458879"/>
    <Language text="Language" Submenu1="English" Submenu2="বাংলা"/>
  <Error text="ERROR!" data="No Value for Calculator" equal="Insufficient data to calculate"/>
  <Result text="Result = "/>
  <Memory a="Ans" b="MR" c="MC" d="M+"/>
Here I've used a previously created project by Ahmed al Razi. (I'm apologizing to him because I've not take permission from him to publish) I've added some additional functionality and the multilingual feature.
Data Loading:
To load data in application runtime, I've used a function as bellow
 private void languageClick(object sender, RoutedEventArgs e)
    if (((MenuItem)sender).Tag.ToString() == "bn.xml")
        Bengoly.IsChecked = true;
        English.IsChecked = false;
         Bengoly.IsChecked = false;
         English.IsChecked = true;
 public void xml(string path)
  System.IO.StreamReader sr = new System.IO.StreamReader(@path);
  XmlTextReader xtr = new XmlTextReader(sr);
  XmlDocument Calculator = new XmlDocument();
  XmlNode n = Calculator.SelectSingleNode("Calculator/Title");
  ///Setting Title text
  this.Title = n.Attributes[0].Value;
  n = Calculator.SelectSingleNode("Calculator/Button/Seven");
 /// Setting Button text
seven.Content = n.Attributes[0].Value;
eight.Content = n.NextSibling.Attributes[0].Value;
nine.Content = n.NextSibling.NextSibling.Attributes[0].Value;
sqr.Content = n.NextSibling.NextSibling.NextSibling.Attributes[0].Value;
six.Content = n.PreviousSibling.Attributes[0].Value;
n = Calculator.SelectSingleNode("Calculator/Memory");
Ans.Content = n.Attributes[0].Value;
MR.Content = n.Attributes[1].Value;
MC.Content = n.Attributes[2].Value;
M.Content = n.Attributes[3].Value;
///Setting menu text
n = Calculator.SelectSingleNode("Calculator/Menu");
file.Header = n.FirstChild.Attributes[0].Value;
exit_This.Header = n.FirstChild.Attributes[1].Value;
view.Header = n.FirstChild.NextSibling.Attributes[0].Value;
stdMenu.Header = n.FirstChild.NextSibling.Attributes[1].Value;
lang.Header = n.LastChild.Attributes[0].Value;
English.Header = n.LastChild.Attributes[1].Value;
Bengoly.Header = n.LastChild.Attributes[2].Value;
about.Header = n.LastChild.PreviousSibling.Attributes[0].Value;
///Setting global texts
help = n.LastChild.PreviousSibling.Attributes[1].Value;
n = Calculator.SelectSingleNode("Calculator/Error");
error = n.Attributes[0].Value;
error_no_data = n.Attributes[1].Value;
error_equal = n.Attributes[2].Value;
Result = n.NextSibling.Attributes[0].Value;
Conclusion: I know that what I've made is nothing. But I've published this in web so that other sophisticated programmer can help to improve functionality of Multilingual approach.


No comments:

Post a Comment

Communicate with Authore