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. Calling SatelliteAssembly in C#.NET

Calling SatelliteAssembly in C#.NET

Scheduled Pinned Locked Moved C#
csharplearning
4 Posts 2 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.
  • P Offline
    P Offline
    PranavThakur
    wrote on last edited by
    #1

    Hi, I have created two different satellite assemblies corresponding to two languages specific resource files -english and french.I am calling these assemblies on the basis of the language selected from the combobox and changing the label text.Please refer to the code below:- private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { try { ResourceManager rm = null; if (comboBox1.Text == "English") { rm = new ResourceManager("Satellite.en-US", Assembly.GetExecutingAssembly()); label1.Text = rm.GetString("String1"); } else if (comboBox1.Text == "French") { rm = new ResourceManager("Satellite.fr-FR", Assembly.GetExecutingAssembly()); label1.Text = rm.GetString("String1"); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } } The above code works fine and the label text is getting changed according the language selected.But I don't want to do this: rm = new ResourceManager("Satellite.en-US", Assembly.GetExecutingAssembly()); I want, .NET to detect the current culture of the system and refer the required dll.If the current culture is french then .NET should refer the french dll automatically.Is there any way to do this task.Actually in future if any new language is added then there is no need to add anything in the code.

    N 1 Reply Last reply
    0
    • P PranavThakur

      Hi, I have created two different satellite assemblies corresponding to two languages specific resource files -english and french.I am calling these assemblies on the basis of the language selected from the combobox and changing the label text.Please refer to the code below:- private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { try { ResourceManager rm = null; if (comboBox1.Text == "English") { rm = new ResourceManager("Satellite.en-US", Assembly.GetExecutingAssembly()); label1.Text = rm.GetString("String1"); } else if (comboBox1.Text == "French") { rm = new ResourceManager("Satellite.fr-FR", Assembly.GetExecutingAssembly()); label1.Text = rm.GetString("String1"); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } } The above code works fine and the label text is getting changed according the language selected.But I don't want to do this: rm = new ResourceManager("Satellite.en-US", Assembly.GetExecutingAssembly()); I want, .NET to detect the current culture of the system and refer the required dll.If the current culture is french then .NET should refer the french dll automatically.Is there any way to do this task.Actually in future if any new language is added then there is no need to add anything in the code.

      N Offline
      N Offline
      NassosReyzidis
      wrote on last edited by
      #2

      You can to that. ResourceManager rm = new ResourceManager( "Satellite"+System.Globalization.CultureInfo.CurrentCulture.Name, Assembly.GetExecutingAssembly() ); Nassos

      GanDad

      P 1 Reply Last reply
      0
      • N NassosReyzidis

        You can to that. ResourceManager rm = new ResourceManager( "Satellite"+System.Globalization.CultureInfo.CurrentCulture.Name, Assembly.GetExecutingAssembly() ); Nassos

        GanDad

        P Offline
        P Offline
        PranavThakur
        wrote on last edited by
        #3

        Thanks for your reply.Now i need to assigned ResourceManager instance only once.

        modified on Wednesday, December 05, 2007 5:26:42 AM

        P 1 Reply Last reply
        0
        • P PranavThakur

          Thanks for your reply.Now i need to assigned ResourceManager instance only once.

          modified on Wednesday, December 05, 2007 5:26:42 AM

          P Offline
          P Offline
          PranavThakur
          wrote on last edited by
          #4

          Going little ahead with the same topic(Satellite assembly),i have to upgrade my code. I have initialize resource manager as:- ResourceManager rm = new ResourceManager("Satellite." + System.Globalization.CultureInfo.CurrentCulture.Name, Assembly.GetExecutingAssembly()); From the above code the application automatically detects the current culture of the system.Depending on the current culture I am setting the labels text on a form like this:- private void button1_Click(object sender, EventArgs e) { SetText(this); } void SetText(Control ctl) { string text = rm.GetString(ctl.Name); if (text != null) ctl.Text = text; foreach (Control ctl1 in ctl.Controls) { SetText(ctl1); } } I am trying to find out a way by which my application set the Labels text itself when ever the system language changes. I mean i want to get rid of SetText() method written above.Is there any way by which I don't have to write any method like SetText() for setting all my controls text.If you have any idea then please let me know. Thanks.

          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