Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Please Help me

Please Help me

Scheduled Pinned Locked Moved C#
csharpdatabasehelpquestion
15 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arunkumar Koloth
    wrote on last edited by
    #1

    Hai, friends Iam new to develop a application with multiple language in c#. i writed program for getting translated texts from database. and i put it in the form1's code event but it work only for the form1 i would like to get my translation to all my form my application have and each and every message showing in message box. so where should i put this translation code? in the program.cs page? can anyone Help me by a small exmple? Please Help me :( Arunkumar.T

    P L B A 4 Replies Last reply
    0
    • A Arunkumar Koloth

      Hai, friends Iam new to develop a application with multiple language in c#. i writed program for getting translated texts from database. and i put it in the form1's code event but it work only for the form1 i would like to get my translation to all my form my application have and each and every message showing in message box. so where should i put this translation code? in the program.cs page? can anyone Help me by a small exmple? Please Help me :( Arunkumar.T

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You need to read up on something called Separation of Concerns. There are plenty of C# examples that you should be able to get an understanding of. You should separate the translation code out into a separate cless. Good luck.

      Forgive your enemies - it messes with their heads

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      1 Reply Last reply
      0
      • A Arunkumar Koloth

        Hai, friends Iam new to develop a application with multiple language in c#. i writed program for getting translated texts from database. and i put it in the form1's code event but it work only for the form1 i would like to get my translation to all my form my application have and each and every message showing in message box. so where should i put this translation code? in the program.cs page? can anyone Help me by a small exmple? Please Help me :( Arunkumar.T

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Which UI-framework are you targetting? WPF[^] or WinForms[^]? :)

        Bastard Programmer from Hell :suss:

        A 1 Reply Last reply
        0
        • L Lost User

          Which UI-framework are you targetting? WPF[^] or WinForms[^]? :)

          Bastard Programmer from Hell :suss:

          A Offline
          A Offline
          Addy Tas
          wrote on last edited by
          #4

          Trying to talk him in to taking a look at MVVM? Cheers (and regards from Sinterklaas ;) ) AT

          Cogito ergo sum

          L 1 Reply Last reply
          0
          • A Addy Tas

            Trying to talk him in to taking a look at MVVM? Cheers (and regards from Sinterklaas ;) ) AT

            Cogito ergo sum

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Addy Tas wrote:

            Trying to talk him in to taking a look at MVVM?

            Wouldn't hurt, but I was trying to talk him into taking a look at MSDN :-D

            Addy Tas wrote:

            Cheers (and regards from Sinterklaas ;) ) AT

            He'll have another chance at abducting me to Spain next year :)

            Bastard Programmer from Hell :suss:

            1 Reply Last reply
            0
            • A Arunkumar Koloth

              Hai, friends Iam new to develop a application with multiple language in c#. i writed program for getting translated texts from database. and i put it in the form1's code event but it work only for the form1 i would like to get my translation to all my form my application have and each and every message showing in message box. so where should i put this translation code? in the program.cs page? can anyone Help me by a small exmple? Please Help me :( Arunkumar.T

              B Offline
              B Offline
              BillWoodruff
              wrote on last edited by
              #6

              Please clarify: is this WinForms, or Web based, or ... ? Also, exactly what do you mean by "translate" here: what exactly is the "translation code" ? 1. you could be saying you are pulling data from a database in one language, and then translating it yourself in your own code (or via some Web service, or by interacting with other software components) into other (multiple ?) languages, so different languages might be displayed in different Forms. 2. you could be referring to the issue of localization here, but I seriously doubt that. 3. or, are you saying you want to take this "translated text" you retrieved from the DataBase, which is already translated into one-and-only-one language, and display it in more than one Form: so the same content, in the same language is shown in every Form ? And, where do MessageBoxes come into the action here: where does the content of the MessageBoxes come from ? My guess is that you mean #1, but it would be good to know that for sure.

              "Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill

              P A 2 Replies Last reply
              0
              • B BillWoodruff

                Please clarify: is this WinForms, or Web based, or ... ? Also, exactly what do you mean by "translate" here: what exactly is the "translation code" ? 1. you could be saying you are pulling data from a database in one language, and then translating it yourself in your own code (or via some Web service, or by interacting with other software components) into other (multiple ?) languages, so different languages might be displayed in different Forms. 2. you could be referring to the issue of localization here, but I seriously doubt that. 3. or, are you saying you want to take this "translated text" you retrieved from the DataBase, which is already translated into one-and-only-one language, and display it in more than one Form: so the same content, in the same language is shown in every Form ? And, where do MessageBoxes come into the action here: where does the content of the MessageBoxes come from ? My guess is that you mean #1, but it would be good to know that for sure.

                "Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill

                P Offline
                P Offline
                Peter_in_2780
                wrote on last edited by
                #7

                I'm guessing here, but the OP's question smells to me like localisation. Cheers, Peter

                Software rusts. Simon Stephenson, ca 1994.

                1 Reply Last reply
                0
                • B BillWoodruff

                  Please clarify: is this WinForms, or Web based, or ... ? Also, exactly what do you mean by "translate" here: what exactly is the "translation code" ? 1. you could be saying you are pulling data from a database in one language, and then translating it yourself in your own code (or via some Web service, or by interacting with other software components) into other (multiple ?) languages, so different languages might be displayed in different Forms. 2. you could be referring to the issue of localization here, but I seriously doubt that. 3. or, are you saying you want to take this "translated text" you retrieved from the DataBase, which is already translated into one-and-only-one language, and display it in more than one Form: so the same content, in the same language is shown in every Form ? And, where do MessageBoxes come into the action here: where does the content of the MessageBoxes come from ? My guess is that you mean #1, but it would be good to know that for sure.

                  "Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill

                  A Offline
                  A Offline
                  Arunkumar Koloth
                  wrote on last edited by
                  #8

                  Hai thank you for your answers guys i am trying to make a windows application in c#. this is my database table structure f_textinenglish,f_language_code,f_texttranslated welcome 101 welcome welcome 102 bienvenida welcome 103 welkom i have a combo box in first form when a user change language there all all labels and all forms change to the selected language. i writed program for getting translated text for each control in the form1. my question is where should i put this code for getting tranlation globally(means all form and all controls)? i thing you understand what is my problem . Please Help Me. Thank you Arunkumar.T

                  B 1 Reply Last reply
                  0
                  • A Arunkumar Koloth

                    Hai thank you for your answers guys i am trying to make a windows application in c#. this is my database table structure f_textinenglish,f_language_code,f_texttranslated welcome 101 welcome welcome 102 bienvenida welcome 103 welkom i have a combo box in first form when a user change language there all all labels and all forms change to the selected language. i writed program for getting translated text for each control in the form1. my question is where should i put this code for getting tranlation globally(means all form and all controls)? i thing you understand what is my problem . Please Help Me. Thank you Arunkumar.T

                    B Offline
                    B Offline
                    BillWoodruff
                    wrote on last edited by
                    #9

                    Arunkumar.Koloth wrote:

                    Hai thank you for your answers guys

                    Sri Arunkamar, you are indeed dealing with a problem of system language localisation, and there are powerful solutions within .NET for support of multiple languages, that use the internal facilities of the OS. Specifically you want to be using resource files here. There are lots of articles on CP about localisation, just search. Here's one that's still getting current positive votes now, even though its eight years old[^]. So why are you writing your own replacement, when built-in multi-language support is a given ? "Jangal mein hain bole koyal ku, ku, kuu!" ... "In the jungle the cuckoos are crying ku ku kuu!" ... from the song "Kahin Ag Lage" in the movie, "Taal.[^]

                    "Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill

                    1 Reply Last reply
                    0
                    • A Arunkumar Koloth

                      Hai, friends Iam new to develop a application with multiple language in c#. i writed program for getting translated texts from database. and i put it in the form1's code event but it work only for the form1 i would like to get my translation to all my form my application have and each and every message showing in message box. so where should i put this translation code? in the program.cs page? can anyone Help me by a small exmple? Please Help me :( Arunkumar.T

                      A Offline
                      A Offline
                      Abhinav S
                      wrote on last edited by
                      #10

                      Arunkumar.Koloth wrote:

                      can anyone Help me by a small exmple?

                      I recommend picking up a good book and reading some chapters on ADO.Net. This should give you a fair idea plus a lot of sample code as well.

                      Too much of heaven can bring you underground Heaven can always turn around Too much of heaven, our life is all hell bound Heaven, the kill that makes no sound

                      A 1 Reply Last reply
                      0
                      • A Abhinav S

                        Arunkumar.Koloth wrote:

                        can anyone Help me by a small exmple?

                        I recommend picking up a good book and reading some chapters on ADO.Net. This should give you a fair idea plus a lot of sample code as well.

                        Too much of heaven can bring you underground Heaven can always turn around Too much of heaven, our life is all hell bound Heaven, the kill that makes no sound

                        A Offline
                        A Offline
                        Arunkumar Koloth
                        wrote on last edited by
                        #11

                        Hai again this is my class code

                        using System;
                        using System.Collections.Generic;
                        using System.Text;
                        using System.Data.SQLite;

                        namespace sample
                        {
                        class translation
                        {

                            private SQLiteConnection sql\_con;
                            private SQLiteCommand sql\_cmd;
                            private SQLiteDataAdapter DB;
                            private SQLiteDataReader dr;
                        
                            public void LoadTranslations(int languagecode)
                            {
                                string\[\] TextinTranslatedArray = new string\[200\];
                                string\[\] TextinEnglishArray = new string\[\] { "Admin","User","ZHome","UserName"};
                        
                                for (int i = 0; i < TextinEnglishArray.Length; i++)
                                {
                                    string sql;
                                    sql = "SELECT f\_text\_translated FROM t01\_text\_translation WHERE f\_text\_english='" + TextinEnglishArray\[i\] + "'AND f\_language\_code='" + languagecode + "'";
                                    sql\_cmd = sql\_con.CreateCommand();
                                    sql\_cmd.CommandText = sql;
                                    dr=sql\_cmd.ExecuteReader();
                                    TextinTranslatedArray\[i\] = dr.GetValue(0).ToString();
                                }
                        
                                sql\_con.Close();
                            }
                             private void SetConnection()
                            {
                                sql\_con = new SQLiteConnection("Data Source=DATA.sl3;Version=3;New=False;Compress=True;");
                            }
                        
                        
                        }
                        

                        }

                        AND WHEN I CREATE A OBJECT FOR THIS CLASS IN MY FORM I GOT SOME ERROR

                        using System;
                        using System.Collections.Generic;
                        using System.ComponentModel;
                        using System.Data;
                        using System.Drawing;
                        using System.Text;
                        using System.Windows.Forms;

                        namespace sample
                        {
                        class tr=new translation();
                        public partial class Form1 : Form
                        {
                        public Form1()
                        {
                        InitializeComponent();
                        }

                            private void Form1\_Load(object sender, EventArgs e)
                            {
                        
                            }
                        }
                        

                        }

                        Error is :- Error 3 { expected C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 13 sample Error 4 Invalid token '=' in class, struct, or interface member declaration C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 13 sample Error 5 Class, struct, or interface method must have a return type C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 18 sample Error 6 } expected C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 24 2 sample What is this error? Please Help me Arunkumar.T

                        P W 2 Replies Last reply
                        0
                        • A Arunkumar Koloth

                          Hai again this is my class code

                          using System;
                          using System.Collections.Generic;
                          using System.Text;
                          using System.Data.SQLite;

                          namespace sample
                          {
                          class translation
                          {

                              private SQLiteConnection sql\_con;
                              private SQLiteCommand sql\_cmd;
                              private SQLiteDataAdapter DB;
                              private SQLiteDataReader dr;
                          
                              public void LoadTranslations(int languagecode)
                              {
                                  string\[\] TextinTranslatedArray = new string\[200\];
                                  string\[\] TextinEnglishArray = new string\[\] { "Admin","User","ZHome","UserName"};
                          
                                  for (int i = 0; i < TextinEnglishArray.Length; i++)
                                  {
                                      string sql;
                                      sql = "SELECT f\_text\_translated FROM t01\_text\_translation WHERE f\_text\_english='" + TextinEnglishArray\[i\] + "'AND f\_language\_code='" + languagecode + "'";
                                      sql\_cmd = sql\_con.CreateCommand();
                                      sql\_cmd.CommandText = sql;
                                      dr=sql\_cmd.ExecuteReader();
                                      TextinTranslatedArray\[i\] = dr.GetValue(0).ToString();
                                  }
                          
                                  sql\_con.Close();
                              }
                               private void SetConnection()
                              {
                                  sql\_con = new SQLiteConnection("Data Source=DATA.sl3;Version=3;New=False;Compress=True;");
                              }
                          
                          
                          }
                          

                          }

                          AND WHEN I CREATE A OBJECT FOR THIS CLASS IN MY FORM I GOT SOME ERROR

                          using System;
                          using System.Collections.Generic;
                          using System.ComponentModel;
                          using System.Data;
                          using System.Drawing;
                          using System.Text;
                          using System.Windows.Forms;

                          namespace sample
                          {
                          class tr=new translation();
                          public partial class Form1 : Form
                          {
                          public Form1()
                          {
                          InitializeComponent();
                          }

                              private void Form1\_Load(object sender, EventArgs e)
                              {
                          
                              }
                          }
                          

                          }

                          Error is :- Error 3 { expected C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 13 sample Error 4 Invalid token '=' in class, struct, or interface member declaration C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 13 sample Error 5 Class, struct, or interface method must have a return type C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 18 sample Error 6 } expected C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 24 2 sample What is this error? Please Help me Arunkumar.T

                          P Offline
                          P Offline
                          Pete OHanlon
                          wrote on last edited by
                          #12

                          Look for the line that has class = in it. There are two things wrong with it. First, you don't declare variables outside a class. This should be inside the class declaration. Second, you don't declare variables using class, you need to use the class name to declare the member here.

                          Forgive your enemies - it messes with their heads

                          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                          My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                          1 Reply Last reply
                          0
                          • A Arunkumar Koloth

                            Hai again this is my class code

                            using System;
                            using System.Collections.Generic;
                            using System.Text;
                            using System.Data.SQLite;

                            namespace sample
                            {
                            class translation
                            {

                                private SQLiteConnection sql\_con;
                                private SQLiteCommand sql\_cmd;
                                private SQLiteDataAdapter DB;
                                private SQLiteDataReader dr;
                            
                                public void LoadTranslations(int languagecode)
                                {
                                    string\[\] TextinTranslatedArray = new string\[200\];
                                    string\[\] TextinEnglishArray = new string\[\] { "Admin","User","ZHome","UserName"};
                            
                                    for (int i = 0; i < TextinEnglishArray.Length; i++)
                                    {
                                        string sql;
                                        sql = "SELECT f\_text\_translated FROM t01\_text\_translation WHERE f\_text\_english='" + TextinEnglishArray\[i\] + "'AND f\_language\_code='" + languagecode + "'";
                                        sql\_cmd = sql\_con.CreateCommand();
                                        sql\_cmd.CommandText = sql;
                                        dr=sql\_cmd.ExecuteReader();
                                        TextinTranslatedArray\[i\] = dr.GetValue(0).ToString();
                                    }
                            
                                    sql\_con.Close();
                                }
                                 private void SetConnection()
                                {
                                    sql\_con = new SQLiteConnection("Data Source=DATA.sl3;Version=3;New=False;Compress=True;");
                                }
                            
                            
                            }
                            

                            }

                            AND WHEN I CREATE A OBJECT FOR THIS CLASS IN MY FORM I GOT SOME ERROR

                            using System;
                            using System.Collections.Generic;
                            using System.ComponentModel;
                            using System.Data;
                            using System.Drawing;
                            using System.Text;
                            using System.Windows.Forms;

                            namespace sample
                            {
                            class tr=new translation();
                            public partial class Form1 : Form
                            {
                            public Form1()
                            {
                            InitializeComponent();
                            }

                                private void Form1\_Load(object sender, EventArgs e)
                                {
                            
                                }
                            }
                            

                            }

                            Error is :- Error 3 { expected C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 13 sample Error 4 Invalid token '=' in class, struct, or interface member declaration C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 13 sample Error 5 Class, struct, or interface method must have a return type C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 11 18 sample Error 6 } expected C:\Users\arun\Documents\Visual Studio 2005\Projects\sample\sample\Form1.cs 24 2 sample What is this error? Please Help me Arunkumar.T

                            W Offline
                            W Offline
                            Wayne Gaylard
                            wrote on last edited by
                            #13

                            Arunkumar.Koloth wrote:

                            class tr=new translation();

                            I don't know what you meant to do with this line, but A. If you want to declare another class in the same file as a file with a Partial class declaration, it has to be after the Partial class declaration. B. If you wanted to declare an instance of the translation class for use in your form class, it has to be declared inside the form class and cannot be declared as a class. It should be someting like this:-

                            public partial class Form1 : Form
                            {
                                translation tr = new translation();
                            
                                public Form1()
                                {
                                }
                            }
                            

                            When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                            A 1 Reply Last reply
                            0
                            • W Wayne Gaylard

                              Arunkumar.Koloth wrote:

                              class tr=new translation();

                              I don't know what you meant to do with this line, but A. If you want to declare another class in the same file as a file with a Partial class declaration, it has to be after the Partial class declaration. B. If you wanted to declare an instance of the translation class for use in your form class, it has to be declared inside the form class and cannot be declared as a class. It should be someting like this:-

                              public partial class Form1 : Form
                              {
                                  translation tr = new translation();
                              
                                  public Form1()
                                  {
                                  }
                              }
                              

                              When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                              A Offline
                              A Offline
                              Arunkumar Koloth
                              wrote on last edited by
                              #14

                              Thanks it works

                              W 1 Reply Last reply
                              0
                              • A Arunkumar Koloth

                                Thanks it works

                                W Offline
                                W Offline
                                Wayne Gaylard
                                wrote on last edited by
                                #15

                                Glad to help :)

                                When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups