Multilingual Application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Luc The Perverse

    Multilingual Application

    Hello! I am looking for a good way to make an application multilingual.
    Danish/English for now (but I don't want to preclude more than two languages
    eventually) Every dialog will have an option for changing language (except
    simple dialog boxes)

    Here is what I am envisioning - I want to make sure I am on the right track:

    There is a global language object which handles giving out strings, has
    functions for setting/retrieving the current language and giving an array of
    all available languages (in string format).

    All the strings are contained in a giant hashtable and have string
    references. Strings are accessed like this (this is an example only):

    STable["SUREDELETE ?"]

    If the current language is english this could return the string "Are you
    sure that you want to delete this file?"

    I'm planning to embed all the strings into the program (a giant function
    which contains all the strings and populates the string table on first
    use) - so they could be easily edited, and avoid having to access strings
    from an outside file. This is a small application, so I am not too woried
    about the size of the function.

    Every form would have an "updatecomponen ts" function which would set the
    text of all affected components to their respective language.

    I still need a way to trigger this updatecomponent s if the language is
    changed in another window, particularly if I will be making use of modeless
    dialogs keeping language a global setting. Maybe windows message? (Better
    ideas?)

    Does this system for handling changing languages sound good?

    Oh BTW - I am using Visual Studio 2003, if that makes any difference.

    --
    LTP

    :)


  • Marc Gravell

    #2
    Re: Multilingual Application

    I can't help thinking that you are inventing the wheel... and there is
    more than just the words... display formats (such as comma/period
    separators, etc) can all change. Most of this is already covered in
    culture-sensitive resource files... I can't remember exactly which
    features were added/changed in 2.0, but in VS2005 it is quite easy to
    link captions etc directly to resource entries using Localizable and
    Language.

    Note that some Control's will respond unkindly to the UI locale
    changing underneath them... perhaps consider setting the UI-thread's
    locale at the start of the app; do they genuinely change language so
    often that you can't have this take effect on the next app restart
    (which you could initiate)? Hooking into some global mechanism (such
    as event) seems like a good way to start a memory "leak" (quoted as
    not a true leak... just that the global event will still have
    visibility of all the subscribers unless they *always* remember to
    unsubscribe).

    Marc


    Comment

    • Johnny Jörgensen

      #3
      Re: Multilingual Application

      This might be an idea for you - looks really nice and easy to use to me...



      Held og lykke,
      Johnny J.




      "Luc The Perverse" <sll_noSpamlici ous_z_XXX_m@cc. usu.eduwrote in message
      news:26fai4-hq9.ln1@loki.cm ears.id.au...
      Hello! I am looking for a good way to make an application multilingual.
      Danish/English for now (but I don't want to preclude more than two
      languages eventually) Every dialog will have an option for changing
      language (except simple dialog boxes)
      >
      Here is what I am envisioning - I want to make sure I am on the right
      track:
      >
      There is a global language object which handles giving out strings, has
      functions for setting/retrieving the current language and giving an array
      of all available languages (in string format).
      >
      All the strings are contained in a giant hashtable and have string
      references. Strings are accessed like this (this is an example only):
      >
      STable["SUREDELETE ?"]
      >
      If the current language is english this could return the string "Are you
      sure that you want to delete this file?"
      >
      I'm planning to embed all the strings into the program (a giant function
      which contains all the strings and populates the string table on first
      use) - so they could be easily edited, and avoid having to access strings
      from an outside file. This is a small application, so I am not too woried
      about the size of the function.
      >
      Every form would have an "updatecomponen ts" function which would set the
      text of all affected components to their respective language.
      >
      I still need a way to trigger this updatecomponent s if the language is
      changed in another window, particularly if I will be making use of
      modeless dialogs keeping language a global setting. Maybe windows
      message? (Better ideas?)
      >
      Does this system for handling changing languages sound good?
      >
      Oh BTW - I am using Visual Studio 2003, if that makes any difference.
      >
      --
      LTP
      >
      :)
      >

      Comment

      • Cowboy \(Gregory A. Beamer\)

        #4
        Re: Multilingual Application

        It is much easier to use resouce files, which will act a lot like a state
        machine (much like your hashtable). And, this is already built into .NET, so
        you do not have to write the mechanism.

        You have two choices in the default implementation.

        1. Global resources - single file for all resources. This is great for items
        taht appear on multiple pages, like button captions, etc.
        2. Page resources - best for localizing a single page

        If you go to MSDN, however, Michele Bustamante has written a wonderful
        article on using external resource DLLs and databases for your localization
        efforts.

        --
        Gregory A. Beamer
        MVP; MCP: +I, SE, SD, DBA

        Co-author: Microsoft Expression Web Bible (upcoming)

        *************** *************** *************** ***
        Think outside the box!
        *************** *************** *************** ***
        "Luc The Perverse" <sll_noSpamlici ous_z_XXX_m@cc. usu.eduwrote in message
        news:26fai4-hq9.ln1@loki.cm ears.id.au...
        Hello! I am looking for a good way to make an application multilingual.
        Danish/English for now (but I don't want to preclude more than two
        languages eventually) Every dialog will have an option for changing
        language (except simple dialog boxes)
        >
        Here is what I am envisioning - I want to make sure I am on the right
        track:
        >
        There is a global language object which handles giving out strings, has
        functions for setting/retrieving the current language and giving an array
        of all available languages (in string format).
        >
        All the strings are contained in a giant hashtable and have string
        references. Strings are accessed like this (this is an example only):
        >
        STable["SUREDELETE ?"]
        >
        If the current language is english this could return the string "Are you
        sure that you want to delete this file?"
        >
        I'm planning to embed all the strings into the program (a giant function
        which contains all the strings and populates the string table on first
        use) - so they could be easily edited, and avoid having to access strings
        from an outside file. This is a small application, so I am not too woried
        about the size of the function.
        >
        Every form would have an "updatecomponen ts" function which would set the
        text of all affected components to their respective language.
        >
        I still need a way to trigger this updatecomponent s if the language is
        changed in another window, particularly if I will be making use of
        modeless dialogs keeping language a global setting. Maybe windows
        message? (Better ideas?)
        >
        Does this system for handling changing languages sound good?
        >
        Oh BTW - I am using Visual Studio 2003, if that makes any difference.
        >
        --
        LTP
        >
        :)
        >

        Comment

        • Cowboy \(Gregory A. Beamer\)

          #5
          Re: Multilingual Application

          That looks like a nice tool. :-)

          --
          Gregory A. Beamer
          MVP; MCP: +I, SE, SD, DBA

          Co-author: Microsoft Expression Web Bible (upcoming)

          *************** *************** *************** ***
          Think outside the box!
          *************** *************** *************** ***
          "Johnny Jörgensen" <jojo@altcom.se wrote in message
          news:ewotGiEnHH A.2296@TK2MSFTN GP03.phx.gbl...
          This might be an idea for you - looks really nice and easy to use to me...
          >

          >
          Held og lykke,
          Johnny J.
          >
          >
          >
          >
          "Luc The Perverse" <sll_noSpamlici ous_z_XXX_m@cc. usu.eduwrote in message
          news:26fai4-hq9.ln1@loki.cm ears.id.au...
          >Hello! I am looking for a good way to make an application multilingual.
          >Danish/English for now (but I don't want to preclude more than two
          >languages eventually) Every dialog will have an option for changing
          >language (except simple dialog boxes)
          >>
          >Here is what I am envisioning - I want to make sure I am on the right
          >track:
          >>
          >There is a global language object which handles giving out strings, has
          >functions for setting/retrieving the current language and giving an array
          >of all available languages (in string format).
          >>
          >All the strings are contained in a giant hashtable and have string
          >references. Strings are accessed like this (this is an example only):
          >>
          >STable["SUREDELETE ?"]
          >>
          >If the current language is english this could return the string "Are you
          >sure that you want to delete this file?"
          >>
          >I'm planning to embed all the strings into the program (a giant function
          >which contains all the strings and populates the string table on first
          >use) - so they could be easily edited, and avoid having to access strings
          >from an outside file. This is a small application, so I am not too
          >woried about the size of the function.
          >>
          >Every form would have an "updatecomponen ts" function which would set the
          >text of all affected components to their respective language.
          >>
          >I still need a way to trigger this updatecomponent s if the language is
          >changed in another window, particularly if I will be making use of
          >modeless dialogs keeping language a global setting. Maybe windows
          >message? (Better ideas?)
          >>
          >Does this system for handling changing languages sound good?
          >>
          >Oh BTW - I am using Visual Studio 2003, if that makes any difference.
          >>
          >--
          >LTP
          >>
          >:)
          >>
          >
          >

          Comment

          • Luc The Perverse

            #6
            Re: Multilingual Application

            "Johnny Jörgensen" <jojo@altcom.se wrote in message
            news:ewotGiEnHH A.2296@TK2MSFTN GP03.phx.gbl...
            This might be an idea for you - looks really nice and easy to use to me...
            >

            >
            Held og lykke,
            Johnny J.
            Wow!

            I have never seen anything like this.

            Too bad it is not freeware ;)

            --
            LTP

            :)


            Comment

            • Luc The Perverse

              #7
              Re: Multilingual Application

              "Marc Gravell" <marc.gravell@g mail.comwrote in message
              news:e281aKEnHH A.3704@TK2MSFTN GP02.phx.gbl...
              >I can't help thinking that you are inventing the wheel...
              That's what I wanted to hear! That means I'm doing it wrong and it will be
              even less work :)
              and there is more than just the words... display formats (such as
              comma/period separators, etc) can all change. Most of this is already
              covered in culture-sensitive resource files... I can't remember exactly
              which features were added/changed in 2.0, but in VS2005 it is quite easy
              to link captions etc directly to resource entries using Localizable and
              Language.
              >
              Note that some Control's will respond unkindly to the UI locale changing
              underneath them... perhaps consider setting the UI-thread's locale at the
              start of the app; do they genuinely change language so often that you
              can't have this take effect on the next app restart (which you could
              initiate)? Hooking into some global mechanism (such as event) seems like a
              good way to start a memory "leak" (quoted as not a true leak... just that
              the global event will still have visibility of all the subscribers unless
              they *always* remember to unsubscribe).
              All of this might be a bigger concern if I were making a much larger
              application. (Understandable - I didn't give a lot of details.)

              Mostly we will be working with static label boxes . . some file stuff, but
              no file names will need translation.

              But I thank you for the good advice - I never would have thought of
              restarting the application to change language - or even having the language
              run in one language its entire execution.

              The application will always have a login screen at the beginning - maybe I
              could have one hard coded multilingual dialog (the login) and then it could
              just be set the entire time.

              If the language weren't going to change then I could just get all the text
              set at dialog initialization - the only text I'd ever need to fetch would be
              some messageboxes.

              Suddenly things are looking up!

              --
              LTP

              :)


              Comment

              • Luc The Perverse

                #8
                Re: Multilingual Application

                "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamMwrote in
                message news:eorwgbInHH A.4592@TK2MSFTN GP05.phx.gbl...
                It is much easier to use resouce files, which will act a lot like a state
                machine (much like your hashtable). And, this is already built into .NET,
                so you do not have to write the mechanism.
                >
                You have two choices in the default implementation.
                >
                1. Global resources - single file for all resources. This is great for
                items taht appear on multiple pages, like button captions, etc.
                2. Page resources - best for localizing a single page
                >
                If you go to MSDN, however, Michele Bustamante has written a wonderful
                article on using external resource DLLs and databases for your
                localization efforts.
                Thank you :)

                --
                LTP

                :)


                Comment

                Working...