Results 1 to 12 of 12

Thread: Languages

  1. #1
    Join Date
    May 2004
    Posts
    17

    Unanswered: Languages

    Hello,

    I'm trying to adapt a database, originally made in Access 97, to use in an
    environment of multiple languages. The idea is that on opening the databse, the user can choose a language (4 types : English, Dutch, French and German). After he choose his languages, the database opens the forms with the correct language in the lables, ...
    I was thinking og giving each lable a code, defining a code table and a language table, changing with a correct VBA module the language...
    Makes this sense? And can somebody give me an example on how I can solve this problem...?

    Thanks.

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I think the easisest way to do this would be seperate forms for each language. There's just so much to change if you hard code it. On the other hand, that creates serious size issues if your db gets more involved.

    If you don't want to do that, you COULD store the desired language as a number in a global variable (eg. 1=English, 2=Dutch, 3=French, 4=German) by creating a new module, and writing this line:

    Global LangInt As Integer

    Then you could use vba to manually set all the captions for your controls based on that global variable, possibly using a case statement:
    Code:
    Select Case LangInt
    Case 1
       firstControl.Caption = "English name"
       secondControl.Caption = "English name"
    Case 2
       firstControl.Caption = "dutch name"
       secondControl.Caption = "dutch name"
    End Select
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    your original idea of using a table is interesting - some untested thoughts:

    tblLangLabels
    LLid, auto PK
    LLformNum, int, the name of the form the label belongs to
    LLctrl, text, the name of the label on the form
    LLtext1, text, the label text in language 1
    LLtext2, text, the label text in language 2 etc



    code in global module:
    global LLset as integer 'language selection 1:English, 2panish 3:whatever


    and DAO code in frmXXX module:

    option explicit
    const LLformNumIs = 1 'each form has it's own number....

    private sub Form_Load()
    dim dabs as database
    dim recs as recordset
    dim strSQL as string
    strSQL = "SELECT LLctrl, "
    select case LLset
    case 1
    strSQL = strSQL & "LLtext1"
    case 2
    strSQL = strSQL & "LLtext2"
    ....etc
    end select
    strSQL = strSQL & " AS LLtext FROM tblLangLabels WHERE LLformNum = " & LLformNumIs & ";"
    set dabs = currentdb
    set recs = dabs.openrecordset(strSQL)
    with recs
    do while not .eof
    me(!LLctrl).caption = !LLtext 'the crucial untested line ---- will it work??????
    .movenext
    loop
    end with
    set recs = nothing
    set dabs = nothing
    end sub

    the downside of doing this (either from a table or hard-coded like Teddy suggests) is that your forms will take longer to load.

    it is tempting to consider a language-selector application that does a one-time rewrite of your forms via code (if the user has selected a different language) and then loads the re-written application. where is our friend Hammbakka? some of his recent questions suggest he is doing something very much like this.

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Another option is to use the Tag property of the label itself. If you set Label.Tag equal to a delimited list(I prefer to use the backwards apostrophe):

    Two`Zwei`Something`Something

    Then when you open the form you can determine the language (I would avoid a global variable, they get lost when a untrapped error occurs) and display the proper piece of the Tag property.

    You will need to have a function that returns the proper piece of the delimited list and then you will also have to loop through all the controls setting up all the labels. You will probably also want to set the Caption for the form. This can also be extended to Reports.

    One problem I see with this solution is displaying language specific characters like accent marks and umlauts. However you can probably get around it with special embedded characters.

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by DCKunkle
    Another option is to use the Tag property of the label itself. If you set Label.Tag equal to a delimited list(I prefer to use the backwards apostrophe):

    Two`Zwei`Something`Something

    Then when you open the form you can determine the language (I would avoid a global variable, they get lost when a untrapped error occurs) and display the proper piece of the Tag property.

    You will need to have a function that returns the proper piece of the delimited list and then you will also have to loop through all the controls setting up all the labels. You will probably also want to set the Caption for the form. This can also be extended to Reports.

    One problem I see with this solution is displaying language specific characters like accent marks and umlauts. However you can probably get around it with special embedded characters.
    WINNER! Hell of a suggestion my friend!
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  6. #6
    Join Date
    May 2004
    Posts
    17
    could be that programming is not my speciality, but more a healthy eager to know, but is'nt this all a little "to difficult". A language is not more than a visualisation of a lable, no...? The data itself stays the same...
    So, if you declare two extra tables : f.e. "Language" : in which you declare the types of languages, each with their own ID and "Code", in which you declare for each language_ID and each code_ID the name of the lables in each of the languages.
    If you open the database, Access should then ask for a language. This triggers the selection of a language_ID which opens the database, within all the forms and reports, in the language choosen compatible with the language_ID.
    Does this sounds clear...?
    If so, can somebody help in programming such a structure....?

    Thanks.

  7. #7
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    239

    Wink Multi language application

    Hi.
    Got any more good ideas to solve your language problem ?

    I just realize that several metods has to be used, depending on:
    - is it a label
    - is it text stored in a table, used in a combo box or list box
    - is it tip text on check box, combo box, text box etc ....
    - is it caption of pages
    - is it caption on buttons
    - is it a message box
    ... and not to mention the default answers in message boxes Yes/No/Cancel.... wow

    As I understand, there is not an easy answer to the language issue.
    But once build in all above, any languages can be used, even Norwegian.

    sincerely
    Vestigo

  8. #8
    Join Date
    Dec 2003
    Posts
    268

    Try using an object model

    Create an object for each form. Store each value as a property. Then based on the language desired then return the values for your variables.

    Load the object using ADO based on the language type.

    I think this would be the easiest way to go about doing this. Only a few objects, no duplication of forms etc. Just some tables to maintain.

  9. #9
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    239

    Question

    Hi.
    I would like to test your input, could you please be a little more specific, an example would be appreciated.

    Thanks

    Sincerely
    Vestigo

  10. #10
    Join Date
    Dec 2003
    Posts
    268

    Later tonight

    I'll dink around with this a little later tonight.

    I don't know if I will be able to get 4 languages out of it, but I will try and come up with an example that is applicable.

    may take a little work, but manageability will be alot easier.

  11. #11
    Join Date
    Dec 2003
    Posts
    268

    Example

    Here is what I came up with quickly. I think if you follow this type of methodology it should meet the needs for what you want it to do. One thing to keep in mind is that you will have to ensure that the values for the controls are going to match what you capture in the table.

    One other thing to remember, is that this object 'LanugageInfo' can be used for any form and the code is completely reusable in the application you are developing. So this means you will not have to create four versions of each form in your application. Thus making the application a lot easier to manage.

    As I think about this more, you can use the object to dynamically assign values for list and combo boxes too. Just refer to the li.lang variable, based on that store the values for each combo/list box in a table then dynmically build the rowsource and fill the list/combo box.

    lemme know what you think.

    MW

    p.s. FYI I used DAO rather than ADO.
    Attached Files Attached Files

  12. #12
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    239

    Smile Multi language application

    Hi.
    Thanks a lot ”mjweyland”. Your code functioned close to perfect.
    Actually, I made something with the same principle, but you did it much more elegant.

    One problem I discovered was when the code was used in sub forms.
    Do you have any suggestion how to solve this issue?

    Sincerely
    Vestigo

    PS!
    As control names can have the same name on various forms I need to distinguish between forms by adding form name to the language table.….. and then I meet another problem, some of my forms is used both as sub forms and main forms :-/
    Last edited by vestigo; 08-04-04 at 04:44.

Posting Permissions

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