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. Web Development
  3. ASP.NET
  4. Bi/multi lingual site

Bi/multi lingual site

Scheduled Pinned Locked Moved ASP.NET
questionannouncement
5 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.
  • G Offline
    G Offline
    Glenn E Lanier II
    wrote on last edited by
    #1

    I am tasked with creating a Spanish version of a working English web site. Is there a proper way to do this? I'm thinking for ease I could duplicate the folder and change the text, but that doesn't seem like an easily scabale solution (when they come back and want two more languages added (or for sites > 10 pages)). --G

    M 1 Reply Last reply
    0
    • G Glenn E Lanier II

      I am tasked with creating a Spanish version of a working English web site. Is there a proper way to do this? I'm thinking for ease I could duplicate the folder and change the text, but that doesn't seem like an easily scabale solution (when they come back and want two more languages added (or for sites > 10 pages)). --G

      M Offline
      M Offline
      Mark Greenwood
      wrote on last edited by
      #2

      The way our company works is that we create a string name for every string in the resource files. For example a string for Name on one page will be unique if it's in webpage1 as it's name will be webpage1.Name, which will then be different from a similiar string on webpage2 because the unique name will be called webpage2.Name etc. We then have a Databast table which contains a unique string link (i.e. webpage1.Name as above) a Locale (i.e. English, Spanish etc) and then the localised (translated) string. We have a control which when a page is rendered iterates through each of the strings held in the resx file - works out what the unique name would be (i.e. on webpage1 it prefixes the name with webpage1 etc) and then based on the chosen locale it extracts the string from the database table and voila - localisable webpages. There are probably many alternatives but the beauty of this is that since all the localised strings are stored as data - it can be exported, edited and added to simply through the db. Plus you can write out the webpage in English - then deliver the strings from your db table to someone to translte into Japanese (for example) and then once the new Japanese strings have been imported you can then have a japanese version of your webite availabe without any rework on the website itself.

      G 2 Replies Last reply
      0
      • M Mark Greenwood

        The way our company works is that we create a string name for every string in the resource files. For example a string for Name on one page will be unique if it's in webpage1 as it's name will be webpage1.Name, which will then be different from a similiar string on webpage2 because the unique name will be called webpage2.Name etc. We then have a Databast table which contains a unique string link (i.e. webpage1.Name as above) a Locale (i.e. English, Spanish etc) and then the localised (translated) string. We have a control which when a page is rendered iterates through each of the strings held in the resx file - works out what the unique name would be (i.e. on webpage1 it prefixes the name with webpage1 etc) and then based on the chosen locale it extracts the string from the database table and voila - localisable webpages. There are probably many alternatives but the beauty of this is that since all the localised strings are stored as data - it can be exported, edited and added to simply through the db. Plus you can write out the webpage in English - then deliver the strings from your db table to someone to translte into Japanese (for example) and then once the new Japanese strings have been imported you can then have a japanese version of your webite availabe without any rework on the website itself.

        G Offline
        G Offline
        Glenn E Lanier II
        wrote on last edited by
        #3

        I like that very much! I'll play around with it. Any chance of seeing that code for the control (glenn_lanier at netzero dot net)? Thanks for the idea - means a little more work to retrofit, but will make going forward much easier. --G

        1 Reply Last reply
        0
        • M Mark Greenwood

          The way our company works is that we create a string name for every string in the resource files. For example a string for Name on one page will be unique if it's in webpage1 as it's name will be webpage1.Name, which will then be different from a similiar string on webpage2 because the unique name will be called webpage2.Name etc. We then have a Databast table which contains a unique string link (i.e. webpage1.Name as above) a Locale (i.e. English, Spanish etc) and then the localised (translated) string. We have a control which when a page is rendered iterates through each of the strings held in the resx file - works out what the unique name would be (i.e. on webpage1 it prefixes the name with webpage1 etc) and then based on the chosen locale it extracts the string from the database table and voila - localisable webpages. There are probably many alternatives but the beauty of this is that since all the localised strings are stored as data - it can be exported, edited and added to simply through the db. Plus you can write out the webpage in English - then deliver the strings from your db table to someone to translte into Japanese (for example) and then once the new Japanese strings have been imported you can then have a japanese version of your webite availabe without any rework on the website itself.

          G Offline
          G Offline
          Glenn E Lanier II
          wrote on last edited by
          #4

          Mark, In working on this, I've created a literal for each of my bits of text (blah blah blah). I have other literals that are updated based on code execution, so that is the reason all literals start with ABCD. In Page_Load, I do something like: string pageName = "UniqueName"; languageCode = 1; // Maps to English in database // Global to page TranslateControls(pageName, this.Controls); I then define the TranslateControls method as: private void TranslateControls(string pageName, ControlCollection controls) { for (int i=0; i < controls.Count; i++) { Control ctrl = controls[i]; if (ctrl.HasControls()) { // logger.Trace("Control: {0} has {1} child controls.", ctrl.UniqueID, ctrl.Controls.Count); TranslateControls(pageName, ctrl.Controls); } else { if (ctrl.GetType() == typeof(System.Web.UI.WebControls.Literal)) { // check name if (ctrl.UniqueID.StartsWith("ABCD")) { // Replace with database lookup Literal litTemp = (Literal)ctrl; Database db = new Database(); string textTranslation = db.GetText(pageName, ctrl.UniqueID, languageCode); litTemp.Text = textTranslation; } } } } } Problem is, some controls are ignored -- when logging/stepping through, it appears that they are not part of the ControlCollection. Any thoughts/ideas? Thanks, Glenn --modified to correct cut-and-paste error in sample

          G 1 Reply Last reply
          0
          • G Glenn E Lanier II

            Mark, In working on this, I've created a literal for each of my bits of text (blah blah blah). I have other literals that are updated based on code execution, so that is the reason all literals start with ABCD. In Page_Load, I do something like: string pageName = "UniqueName"; languageCode = 1; // Maps to English in database // Global to page TranslateControls(pageName, this.Controls); I then define the TranslateControls method as: private void TranslateControls(string pageName, ControlCollection controls) { for (int i=0; i < controls.Count; i++) { Control ctrl = controls[i]; if (ctrl.HasControls()) { // logger.Trace("Control: {0} has {1} child controls.", ctrl.UniqueID, ctrl.Controls.Count); TranslateControls(pageName, ctrl.Controls); } else { if (ctrl.GetType() == typeof(System.Web.UI.WebControls.Literal)) { // check name if (ctrl.UniqueID.StartsWith("ABCD")) { // Replace with database lookup Literal litTemp = (Literal)ctrl; Database db = new Database(); string textTranslation = db.GetText(pageName, ctrl.UniqueID, languageCode); litTemp.Text = textTranslation; } } } } } Problem is, some controls are ignored -- when logging/stepping through, it appears that they are not part of the ControlCollection. Any thoughts/ideas? Thanks, Glenn --modified to correct cut-and-paste error in sample

            G Offline
            G Offline
            Glenn E Lanier II
            wrote on last edited by
            #5

            When page is initially loaded, all controls are displayed properly. However, on postback, some controls are missed and appear blank (odd, as they have initial text, and the db.GetText method returns either valid text or ctrl.UniqueID surrounded by underscores).

            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