SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Location
    london, UK
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying website in multiple languages??

    This is driving me nuts

    I have a site in english, and i need the option to display it in other languages. The first language to display it in is Korean

    Anyone know where to begin on this? I was going to use session variables to set the language option, then use a database to fetch the content. is there a better way?



    p.s. i hate clients. 14 f-cking hours i've been at work today

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    I would say your on the right track. You may want to consider cookies instead in order to save their preference of language for their next visit.

  3. #3
    SitePoint Zealot Ripe's Avatar
    Join Date
    Oct 2006
    Location
    Australia
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have elements in your design you want to change, such as navigation, I'll just create a new file for each language with common variable names but with the values in different languages then load whichever file depending on their choice.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,175
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    If you're going to have a lot of different languages, you should look into gettext. You would still need to have translations for every bit of text, but you wouldn't need to replicate every file.

    You might also be able to use the Accept-Language HTTP header to determine what language to use.

    I don't know how the RTL <-> LTR works though, sorry.

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Location
    london, UK
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ripe View Post
    If you have elements in your design you want to change, such as navigation, I'll just create a new file for each language with common variable names but with the values in different languages then load whichever file depending on their choice.
    Quote Originally Posted by Mittineague View Post
    If you're going to have a lot of different languages, you should look into gettext. You would still need to have translations for every bit of text, but you wouldn't need to replicate every file.

    You might also be able to use the Accept-Language HTTP header to determine what language to use.

    I don't know how the RTL <-> LTR works though, sorry.
    hmmm these two things sound a bit beyond my level of experience. Anyway you could dumb it down for me? or provide a tutorial?

    Also, i thought i would have to change the charset and font-family for each new language??? (which seems like a pain)


    And yes, it is just the navigation and some of the content i need to translate, not the entire site

    thanks for your help

  6. #6
    SitePoint Zealot Ripe's Avatar
    Join Date
    Oct 2006
    Location
    Australia
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    english.lang.php
    PHP Code:
    <?php $site_title 'My Site Title in English'?>
    spanish.lang.php
    PHP Code:
    <?php $site_title 'My Site Title in Spanish'?>
    Then your main file would be something like,
    PHP Code:
    <?php include $_SESSION['user_language'] . '.lang.php'?>
    Then when you use the $site_title variable, it'll be different depending on file that is included.

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Location
    london, UK
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ripe View Post
    english.lang.php
    PHP Code:
    <?php $site_title 'My Site Title in English'?>
    spanish.lang.php
    PHP Code:
    <?php $site_title 'My Site Title in Spanish'?>
    Then your main file would be something like,
    PHP Code:
    <?php include $_SESSION['user_language'] . '.lang.php'?>
    Then when you use the $site_title variable, it'll be different depending on file that is included.
    Yep that's how i've done it so far. But i have a problem with character encoding. For example, trying to display Korean characters appear square boxes. This is the part that's confusing me. It has something to do with charset and fonts (i think), but i'm unsure how to approach this.

    Here's some korean copied and pasted, i wonder if it displays correctly

    패션
    음악
    여행

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,175
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    If you're seeing "square boxes" or "question marks" it suggests that you don't have the needed font on your machine. Or maybe your browser settings for Character Encoding are off?

  9. #9
    SitePoint Guru
    Join Date
    Jun 2006
    Posts
    638
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the UTF8 char set...

  10. #10
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your CSS use direction to change the letters from right to left:

    HTML Code:
    text-align: right;
    direction: rtl;


Bookmarks

Posting Permissions

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