Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 624829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:14:35+00:00 2026-05-13T19:14:35+00:00

I followed the following tutorial to build a multilingual webpage using php arrays: http://bytes.com/topic/php/answers/880915-how-develop-multi-lingual-websites-php

  • 0

I followed the following tutorial to build a multilingual webpage using php arrays: http://bytes.com/topic/php/answers/880915-how-develop-multi-lingual-websites-php

the code:

files tree:

locale/
    english.php
    french.php
set_locale.php
index.php

locale/english.php:

<?php

$locale = array(
    'title' => 'Title in English',
    'h1' => 'The following in in English:',
    'p1' => 'This is a sample text, in English'
);
?>

locale/french.php:

<?php
$locale = array(
    'title' => 'Titre en français',
    'h1' => 'Le texte suivant en en français:',
    'p1' => 'Il s\'agit d\'un échantillon de texte, en français.'
);
?>

set_locale.php:

<?php

// Get the language from the query string, or set a default.
($language = @$_GET['lang']) or $language = 'english';

// Set up a list of possible values, and make sure the
// selected language is valid.
$allowed_locales = array('english', 'french');
if(!in_array($language, $allowed_locales)) {
    $language = 'english'; // Set default if it is invalid.
}

// Inlclude the selected language
include "locale/{$language}.php";

// Make it global, so it is accessible everywhere in the code.
$GLOBALS['L'] = $locale;
?>

index.php:

<?php

// Include the "set_locale" script to fetch the locale
// that should be used.
include_once "set_locale.php"

// Print the HTML, using the selected locale.
?>
<html>
    <head>
        <title><?php echo $GLOBALS['L']['title']; ?></title>
    </head>
    <body>
        <h1><?php echo $GLOBALS['L']['h1']; ?></h1>
        <p><?php echo $GLOBALS['L']['p1']; ?></p>
    </body>
</html>

Now, I want to make something to let the user click on a link and change the language

Something like this:

<ul id="language-selection">
   <li><a href="something should go here but I'm not sure what">English</a></li>
   <li><a href="ssomething should go here but I'm not sure what">English</a></li>
</ul>

What’s the best way of doing it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:14:35+00:00Added an answer on May 13, 2026 at 7:14 pm

    Pass language as part of the query string:

    <ul id="language-selection">
       <li><a href="index.php?lang=english">English</a></li>
       <li><a href="index.php?lang=french">English</a></li>
    </ul>
    

    In your code, you are using $_GET['lang'], so this should catch it. You may want to mofify the code if the need be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed the example http://www.dealtaker.com/blog/2010/02/25/kohana-php-3-0-ko3-tutorial-part-5/ I get the following error: ErrorException [ Notice ]:
I'm using Ubuntu 10, python 2.6.5 I'm following this tutorial: http://www.djangobook.com/en/2.0/chapter02 I followed all
i am trying to run google map tutorial using following link http://mobiforge.com/developing/story/using-google-maps-android followed all
I have followed to following great tutorial at : http://blog.blundell-apps.com/simple-inapp-billing-payment/ I have done everything
I followed the following tutorial http://developer.android.com/guide/developing/projects/projects-eclipse.html and I have 2 projects : the starter
I have followed the instructions at http://www.javacodegeeks.com/2011/01/advanced-smartgwt-tutorial-part-1.html and tried to create a simple screen
I've just followed the Railscast tutorial: http://railscasts.com/episodes/262-trees-with-ancestry Is it possible to paginate results from
So I followed this tutorial from Google: http://developer.android.com/resources/tutorials/opengl/opengl-es20.html The triangle is supposed to rotate
I'm using java 6 annotation processing api. I have followed the following excellent tutorial
I followed the instructions in the Android WebView tutorial (at http://developer.android.com/resources/tutorials/views/hello-webview.html ). When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.