Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    MrK
    MrK is offline
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question using language files

    I have a script which is in English, but i need this script to show both English and German.

    the English language already has a language file ( english.php ), so i am going to translate all the English wording to German ( german.php )

    so my question is how can i select the language file,
    i am going to let the user select the language via a flag image

    so when the user clicks on there country flag it will change the site to the requested language etc etc

    i want to use separate language files

    but how ?

    Thanks MrK

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    You could do something like:

    PHP Code:
    <?php session_start(); ?>
    <a href="index.php?lang=eng"> English </a> <a href="index.php?lang=ger"> German </a>

    <?php
    if(!empty($_GET['lang'])){
    if(
    $_GET['lang'] == 'eng'$lang 'english';
    if(
    $_GET['lang'] == 'ger'$lang 'german';
    } elseif (!empty(
    $_SESSION['lang'])){
    $lang $_SESSION['lang']
    }
    if (
    $lang != 'english' && $lang != 'german'){
    $lang 'english';
    }

    $_SESSION['lang'] = $lang;
    include 
    $lang.'.php';
    ?>

  • #3
    MrK
    MrK is offline
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you, i will give this a try later after work

    thanks again

    mrk

  • #4
    MrK
    MrK is offline
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help , got it working



    mrk


  •  

    Posting Permissions

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