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 8263441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:06:12+00:00 2026-06-08T04:06:12+00:00

in a website I am creating I want to include several languages. Below is

  • 0

in a website I am creating I want to include several languages.

Below is how I identify what language should I show.

    <?php
    $pagename = $_SERVER["REQUEST_URI"];
       if (strpos($pagename,'?en') !== false) 
         {
            echo 'english';
here is when I have to include a language template file for english language.
         }
    ?>

My goal is to include language template files instead of duplicating all of my websites for any language.

So what I think about it, is for example in index.php the variable will be the same for all languages, but the content will be changed.

<div id="main">
<?php echo $main_description; ?>
</div>

How should I include a language file for this to work?

$main_description ="this is the main description written in english"
  • 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-06-08T04:06:14+00:00Added an answer on June 8, 2026 at 4:06 am

    You could use something similar to the if statement that you have and include the specific file with all the variables.

    switch ($_GET['lang']) {
        case "en":
            include "lang/en.php";
            break;
        case "es":
            include "lang/es.php";
            break;
        default:
            include "lang/en.php";
    }
    

    But here, all of your strings will be in variables an you have to be careful not to use/overwrite those variables in the rest of your code.

    This page offers a pretty simple and easy to follow example on how to do it JSON encoded language file that the script loads and finds the text you want and returns the translated text.

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

Sidebar

Related Questions

I'm looking for help/advice with creating simple JSP website using equivalent of PHP include+switch
I'm creating a website and I want it also to be prepare for mobile
I'm creating a MetroStyle app and I want to use a website API that
We want to use Orchard for a website. We are creating a custom module/widget
I'm creating a new website, I don't want to link direct to it so
I'm creating an events website using PHP. I have a database with an events
I am creating a basic CMS website using Alfresco Web Quick Start. I want
I'm creating a website with Visual Studio 2010. I want to use a slider
I am creating website (football, soccer) in ASP.NET MVC3 and I want have users
I have folders on a website I am creating that I only want logged

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.