SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Mexico
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow multilingual cms

    I have a cms where the content is stored on a table, we want to make this content translate in different languages so I am looking for a better aproach to make this happened.

    The first idea is to have a table like with the following formation:
    id | language | header | content |
    1 english Traveler <p>blah...
    2 spanish viajero <p>blah...
    3 french ....

    .. this way the table grows in lines adding new content but order is a hassle

    However I found that if i want to add a new language I will need to duplicate a table which will cause me to actually use a script that will export the table reinsert it and do a whole lot of over head. The I decided this aproach instead.

    id | header | content_es | content_es | content_fr ...
    1 Traveler <p>blah... <p>blah ... <p> blah ...

    This way the header (which is pre-defined) remain the same and just a new column gets added each time a new language gets uploaded.

    My point is this, is there a better approach. I have seen a lot of sites uses po files which are pre-defined variables stored on the PHP however this might not be very practical when updating the site with a new language.

    I would like to hear any recomendation... thanks
    Alexandro Colorado

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    most applications that i have seen do this in PHP, not mysql. the over-simplified approach is to create one php file per language. each file defines an array that has one element per phrase used on the website. the string is stored in sprintf format so that when a word needs to be inserted, you don't have to worry about instances where it makes sense to order the inserted words in one language differently then in others.

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    Moscow, Russia
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JZA
    I have a cms where the content is stored on a table, we want to make this content translate in different languages so I am looking for a better aproach to make this happened.

    The first idea is to have a table like with the following formation:
    id | language | header | content |
    1 english Traveler <p>blah...
    2 spanish viajero <p>blah...
    3 french ....

    .. this way the table grows in lines adding new content but order is a hassle

    However I found that if i want to add a new language I will need to duplicate a table which will cause me to actually use a script that will export the table reinsert it and do a whole lot of over head. The I decided this aproach instead.

    id | header | content_es | content_es | content_fr ...
    1 Traveler <p>blah... <p>blah ... <p> blah ...

    This way the header (which is pre-defined) remain the same and just a new column gets added each time a new language gets uploaded.
    Hi, every approach has both advantages and disadvantages, i.e. you can create two, three or more sets of PHP and HTML pages for each language respectively, but if you want to support unlimited number of languages and add additional languages in the future, UI texts/messages better to be stored in the database as you already decided. Check multilanguage database driven websites? and Your opinion on this schema threads for similar problems

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Mexico
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The issue is that the translation should be scalable and the user should make the translation. So if he wants a new language he can register that language and be able to make the translation of all the strings.

    IF we do a file per translation it would be possible but and end user won't be able to interact with the actual file.
    Alexandro Colorado

  5. #5
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i still vote for the PHP option because it will be much faster. you can store the strings in the DB, but when the user is done adding the strings, your app exports the DB to a PHP file.

  6. #6
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    Moscow, Russia
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JZA
    The issue is that the translation should be scalable and the user should make the translation. So if he wants a new language he can register that language and be able to make the translation of all the strings.

    IF we do a file per translation it would be possible but and end user won't be able to interact with the actual file.
    As longneck already said storing translated text within PHP or HTML files offers better performance, so you should consider it as an option. Actually, this may be important for UI texts which are relatively static, but not for content information which changes quite frequently

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Mexico
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So how will I do this with static text, fopen/fwrite?

    And most important how can more than 1 user interact with this file.
    Alexandro Colorado

  8. #8
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    Moscow, Russia
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JZA
    So how will I do this with static text, fopen/fwrite?

    And most important how can more than 1 user interact with this file.
    longneck meant not just file, but PHP file that returns HTML page to client, i.e. UI texts/messages stored as PHP strings (your headers, footers, etc. as HTML tags) for output or as HTML with some embedded PHP code


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
  •