PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Bilingual Application-VBForums
Results 1 to 5 of 5

Thread: Bilingual Application

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    1

    Question Bilingual Application

    Good Afternoon,

    I have been assigned the task of making our currently developed applications bilingual. The requirement is that a language command button be added and the user could click it, changing from English, to Spanish to Vietnamese, etc.

    Based on the selection, selected labels, message, etc. would be displayed in that language.

    I am in the discovery phase and wanted to ask if anyone else has gone down this road and developed this kind of application. Any insight would be helpful.

    Thanks in advance,
    Nancy
    Nancy

  2. #2
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375

    Re: Bilingual Application

    I'm guessing the only way you could do this is to figure out every caption/text that would need changed, and then just go through them all whenever the language is changed, substituting that language for the current. It would be a pretty long thing to set up the first time depending on the size of the application and the number of languages. And you would have to make sure that any other selections throughout the program that rely on text changes are also able to accept the other languages. If there's a quicker or easier way than just changing them all, i would like to hear about it also.
    -Show me on the doll where the music touched you.

  3. #3
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: Bilingual Application

    You can keep a list of all texts to be changed in a file and load it into memory in a module.
    The module then has a function for other objects to query the list of texts.
    vb Code:
    1. 'in each object that needs to be multilanguage
    2. Private Sub SetLanguage()
    3. Dim t As String
    4. Dim Field() As tField
    5.    
    6.     ReDim Field(1)
    7.     Field(0) = NewField(Form.name, Button.name) 'build the list of fields to be updated
    8.     Field(1) = NewField(Form.name, Label.name)
    9.    
    10.     Field = GetText(Field) 'retrieve the texts of the fields
    11.    
    12.     Button.Caption = Field(0).Text 'update the fields
    13.     Label.Caption = Field(0).Text
    14.    
    15. End Sub
    16.  
    17.  
    18. 'in a module
    19. Public Type tField
    20.     Field As String
    21.     Location As String
    22.     Text As String
    23. End Type
    24.  
    25. Public Function NewField(Field As String, Location As String, Optional Text As String = "") As tField
    26.     NewField.Field = Field
    27.     NewField.Location = Location
    28.     NewField.Text = Text
    29. End Function
    30.  
    31. Private Field() As tField
    32.  
    33. Public Function GetText(FieldReq() As tField) As tField()
    34. Dim fr As Long
    35. Dim f As Long
    36.     For fr = 0 To UBound(FieldReq) 'for each field that is to be updated
    37.         For f = 0 To UBound(Field) 'query each field that is in memory
    38.             If FieldReq(fr).Field = Field(f).Field And FieldReq(fr).Location = Field(f).Location Then 'if the field and location match
    39.                 FieldReq(fr).Text = Field(f).Text 'update the text
    40.                 Exit For
    41.             End If
    42.         Next f
    43.     Next fr
    44.     GetText = FieldReq 'return the result
    45. End Function
    46.  
    47. Public Sub LoadLanguageFile(language As String)
    48.     'load the file with the texts into the field array
    49.     'call at the start of the program
    50. End Sub

  4. #4
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington DC
    Posts
    314

    Re: Bilingual Application

    Also, try this for some ideas
    Code:
    Option Explicit
    Const fDefault = "Language.dat"
    Const English = 1
    Const Spanish = 2
    Const Danish = 3
    Dim Language As Integer
    Dim Prompt(2, 3) As String
    Const WhatIsYourLanguage = 1
    Const IsThatRight = 2
    
    Private Sub Form_Load()
    cmdChange.Caption = "Language, lingua, sprog"
    Dim L As String
    Language = English
    If Dir(fDefault) <> "" Then
      Open fDefault For Input As #1
      If Not EOF(1) Then Line Input #1, L
      Close #1
      Select Case L
      Case "2": Language = Spanish
      Case "3": Language = Danish
      End Select
    End If
    Prompt(1, 1) = "What is your language?"
    Prompt(1, 2) = "Como se llama?"
    Prompt(1, 3) = "Hvad hedder du?"
    Prompt(2, 1) = "Is that right?"
    Prompt(2, 2) = "Es verdad?"
    Prompt(2, 3) = "Er det sandt?"
    Call ShowLang
    End Sub
    
    Private Sub cmdChange_Click()
    Dim M As String, L As String
    M = "1 = English"
    M = M + vbLf + "2 = Spanish"
    M = M + vbLf + "3 = Danish"
    M = M + vbLf + vbLf + "Enter 1, 2 or 3"
    Do
      L = InputBox(M, "Enter Language")
      If Len(L) <> 1 Then L = "x"
    Loop While InStr("123", L) = 0
    Language = L
    Call ShowLang
    End Sub
    
    Private Sub ShowLang()
    Select Case Language
    Case 1: lblLang.Caption = "Language is English"
    Case 2: lblLang.Caption = "Lingua es Espanol"
    Case 3: lblLang.Caption = "Sprog er Dansk"
    End Select
    Open fDefault For Output As #1
    Print #1, LTrim$(Str$(Language))
    Close #1
    Label1.Caption = Prompt(WhatIsYourLanguage, Language)
    Label2.Caption = Prompt(IsThatRight, Language)
    End Sub
    Mac

  5. #5
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,487

    Re: Bilingual Application

    Just use a resource File to add all your strings...

    Then in your code have a sub where all captions get changed etc..

    I.E

    Private Sub ChangeLang()
    label1.caption = loadresstring(101)
    label2.caption = loadresstring(102)
    etc....
    end sub

    You can then even have this as a separate .dll so that each language is can be downlloaded separately...
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width