Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

Reading a resource file -> for language settings f.i.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Screaming Eagles 101 - 01 Oct 2007 15:09 GMT
This is not a question but something I found,
it might not be the best solution, but hey, it works... :-)
Thought someone else could also use this, so here it is.

I made 2 resource files, one for Dutch settings, one for English settings
In these resource files I store the control's name as item, and the text
(caption) of the control as its value.

First I check the language and parse this to my subroutine

'Check Language
sLang =
System.Globalization.CultureInfo.CurrentCulture.ToString.ToUpper.Substring(0,
2)

'Then I loop through all the controls:

   Private Sub Setlanguage(ByVal sLang As String)
       Dim ctrl As Control
       Dim rm As Resources.ResourceManager

       If sLang = "NL" Then
           rm = My.Resources.Nederlands.ResourceManager
       Else
           rm = My.Resources.English.ResourceManager
       End If

       For Each ctrl In Me.Controls
           If Not IsNothing(rm.GetString(ctrl.Name)) Then
               ctrl.Text = rm.GetString(ctrl.Name)
           End If
       Next
   End Sub

It's as simple as this....
Signature

Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------

Screaming Eagles 101 - 02 Oct 2007 08:35 GMT
So what if a control has children (other controls).... ?
Like a panel for instance.... ?

   Private Sub Setlanguage(ByVal sLang As String)
       Dim ctrl As Control
       Dim rm As Resources.ResourceManager

       If sLang = "NL" Then
           rm = My.Resources.Nederlands.ResourceManager
       Else
           rm = My.Resources.English.ResourceManager
       End If

       For Each ctrl In Me.Controls
           SetControlCaptions(ctrl, rm)
       Next

       rm = Nothing
   End Sub

   Private Sub SetControlCaptions(ByVal pc As Control, ByVal pr As
Resources.ResourceManager)
       Dim lc As Control
       'recursive if the control has children
       If pc.HasChildren Then
           For Each lc In pc.Controls
               SetControlCaptions(lc, pr)
           Next
       Else
           'Lowest level, no children anymore - set the caption
           If Not IsNothing(pr.GetString(pc.Name)) Then pc.Text =
pr.GetString(pc.Name)
       End If
   End Sub

Signature

Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.