Bilingual Textarea

Discussion in 'JavaScript' started by wuhnder, May 21, 2007.

  1. #1
    Morning all, I am modifying a CMS for a client who requires content to be displayed bilingually, based on the users choice. I have a single <textarea> that I would like to use to contain both languages. What I have in mind is a selector above the box, for example 'Edit English / Edit French' which would toggle reading (and editing) from [eng][/eng] to [fr][/fr] tags between <textarea></textarea>.

    To clarify the html would look something like this:

    <a onclick="toggle(eng)">edit english</a> / <a onclick="toggle(fr)">edit french</a>
    <textarea>
      [eng]This is the english section[/eng]
      [fr]Le bien[/fr]
    </textarea>
    Code (markup):

    I'm after some clues as to how I might implement this, specifically the javascript to get content between tags, and to write between them. The user should not be able to see the french content while editing the english, and vice versa.

    Thanks for reading,
    Huw
     
    wuhnder, May 21, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Why not using different pages for each language. When the user makes his choice ('Edit English / Edit French') simply jump to the proper page. That method will be easier to mantain if later you want to add more languages.
     
    ajsa52, May 21, 2007 IP
  3. lenz

    lenz Member

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    As ajsa52 says. Besides your original solution won't work when JS is off. Different pages will.
     
    lenz, May 21, 2007 IP
  4. wuhnder

    wuhnder Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have a good reason for doing it this way, I don't really want advice on other solutions, I'd just like a pointer as to the code to implement what I outlined in my post. Thanks
     
    wuhnder, May 21, 2007 IP