Translation file for site...how to translate to another language.

Discussion in 'PHP' started by aliks0905, Jan 21, 2008.

  1. #1
    I know theres a similar post on this, but my question is, how do I make the file (in php) that has all the variables like SITE_TITLE, SITE_SLOGAN, etc. and then has the translations?

    Are there any tutorials anyone knows on this? I googled it, but i guess im not getting the right keywords. This is for my site http://psalmi.com its pretty simple. I just need the categories, search, and titles translated to russian.

    please keep in mind, im not a genius at php/mysql, so a tutorial would be very handy.

    Thanks :p
     
    aliks0905, Jan 21, 2008 IP
  2. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #2
    How about downloading a php project such as Zen Cart and seeing how they do it - you'll learn a ton by doing that. One idea would be to have a seperate file for each language which could included depending upon a $_GET variable.

    Brew
     
    Brewster, Jan 21, 2008 IP
  3. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #3
    SmallPotatoes, Jan 21, 2008 IP
  4. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #4
    Easy to do,

    I have this system on http://www.clan-cms.co.uk

    Make a definitions file like, eng.php

    Then all you need to is define each phrase in this file and include it on all of your pages.

    eng.php

    
    define('WELCOME','Welcome to the website!');
    deinfe('TODAY_IS', 'Today is');
    
    PHP:
    Then in your actual webpage, you would display these like,

    <p><?php echo WELCOME; ?></p>
    <p><?php echo TODAY; ?></p>

    So now you could make translations for each definition and save them as say fra.php dan.php etc

    Then in your config or whatever file you include on all pages, you can have a get variabl for the language, when someone sends a lang request you can assign the language setting to a session.

    From the session you include the lang like,

    
    if($_GET['lang'])
    {
    $_SESSION['lang'] = $_GET['lang'];
    require("lang/".$_SESSION['lang'].".php");
    }else{
    require("lang/default_one.php");
    }
    
    PHP:
    To let people get the languages you would need to use a link or drop down linked like,

    page.php?lang=the_lang_filename (Do not add the .php ext)

    Hope it helps, this is just a basic guide but easily to implement.
     
    HuggyStudios, Jan 21, 2008 IP