How to develop site in multi languages

Discussion in 'PHP' started by jg_abad, Aug 30, 2007.

  1. #1
    Hello,
    I m searching for resources provide guidance about develop site in multi languages using PHP.
    please post some resources or provide some guidance for the same.


    thanks
     
    jg_abad, Aug 30, 2007 IP
  2. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #2
    Are you wanting to do automatic or manual translation?
     
    Will.Spencer, Aug 31, 2007 IP
  3. jg_abad

    jg_abad Peon

    Messages:
    903
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Automatic, you have seen some sites where you can find flag of different countries and once you click on flag language will change accordingly.
     
    jg_abad, Aug 31, 2007 IP
  4. gnoztik

    gnoztik Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think GetText will bring you the solution.
     
    gnoztik, Aug 31, 2007 IP
  5. dcristo

    dcristo Illustrious Member

    Messages:
    19,794
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #5
    If your using Wordpress there is a translation plugin.
     
    dcristo, Aug 31, 2007 IP
    jg_abad likes this.
  6. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #6
    Will.Spencer, Aug 31, 2007 IP
    jg_abad likes this.
  7. jg_abad

    jg_abad Peon

    Messages:
    903
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #7
    no i m not using wordpress, i have one site which is selling products online.
     
    jg_abad, Aug 31, 2007 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    It's pretty simple. Make sure this code is available on all pages where the multi language function is needed. (Save it as an external file and include() it if you want.)

    
    <?php
    
    // Where all language files will be stored
    $language_path = 'languages/';
    
    if (!isset($_GET['lang']) OR !@include("{$language_path}lang.{$_GET{['lang']}.php"))
    {
        // Default language
        include("{$language_path}lang.en.php");
    }
    
    ?>
    
    PHP:
    Inside these language files create an array with the text pieces.

    lang.en.php:
    
    <?php
    
    $lang['welcome'] = 'Welcome to my site.';
    $lang['login'] = 'Please log in';
    $lang['error'] = 'An error occurred';
    
    ?>
    
    PHP:
    Now in your main site, use <?php echo $lang['xxx']; ?> instead of the normal text, and it'll be replaced with the appropriate language bit.


    To switch the language while being on the site just add a lang variable to the URL like this: example.com/file.php?lang=en


    The language files need to be saved in this format: lang.xx.php, where xx is the name in the URL that you want to use.
     
    nico_swd, Aug 31, 2007 IP
    jg_abad likes this.
  9. fabriciogr

    fabriciogr Active Member

    Messages:
    958
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    73
    #9
    i've done this a few times.. with a few clients.. though i would recommend translating manually.. automatically translated versions suck.


    anyhow i've transalted sites with babelfish.. all u have to do is create a link on your site sending to babel fish the correct language your translating from and into... something like this:

    http://babelfish.altavista.com/babe...t?lp=en_es&url=http://www.edirectproperty.com

    these are the variables u have at the end:

    lp=en_es (here we translate from english to spanish)
    url=http://www.edirectproperty.com (this is the website we want to translate)
     
    fabriciogr, Aug 31, 2007 IP
  10. jg_abad

    jg_abad Peon

    Messages:
    903
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #10
    i had tried that and i m getting this error "Temporary problem with the foreign-language section. Please try again later. Sorry for the inconvenience."

    any solution??
     
    jg_abad, Aug 31, 2007 IP
  11. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #11
    That generally means that the script is having trouble talking to the translation server, i.e. that Google or Yahoo have temporarily banned your IP.
     
    Will.Spencer, Aug 31, 2007 IP
  12. jg_abad

    jg_abad Peon

    Messages:
    903
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #12
    ohh,than should i wait or any solution for the same?
     
    jg_abad, Aug 31, 2007 IP
  13. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #13
    Wait, or change your servers outbound IP address. :)
     
    Will.Spencer, Aug 31, 2007 IP
  14. jg_abad

    jg_abad Peon

    Messages:
    903
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #14
    thanks let me try to change outbound ip
     
    jg_abad, Aug 31, 2007 IP
  15. chary1112004

    chary1112004 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Thanks Will Spencer!
    Can you introduction more with everyone about your file (lang2). I read instruction in that file but i have error as Viteb. Wait your toturial in nearest day!
    Thanks much!
     
    chary1112004, Nov 28, 2008 IP