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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:33:49+00:00 2026-05-27T21:33:49+00:00

I have 2 languages in my website. I want to include appropriate file according

  • 0

I have 2 languages in my website. I want to include appropriate file according to selected language. For example, <a href='index.php?lang=en'>English</a> and <a href='index.php?lang=tr'>Turkish</a>. If user clicks over first hyperlink (English) I want to display this information (with HTML tags):

<h1>Hello</h1>
How are you

Otherwise:

<h1>Selam</h1>
Nasılsın

I also dont want user selected language to change if user go to other page inside website.

How can I do that?

  • 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-27T21:33:50+00:00Added an answer on May 27, 2026 at 9:33 pm

    You could use .ini files to hold the translated versions of you text for example, en.ini will contain:

    hello    = "Hello"
    greeting = "How are you"
    

    While tr.ini will contain:

    hello    = "Selam"
    greeting = "Nasılsın"
    

    Both are simple text files (saved in UTF-8 format).
    Now you can see that the strings have common names in all languages (hello & greeting) which cab be used in the code like this:

    // First, load the appropriate language file:
    
    $lang = "en";
    $strings = parse_ini_file( "$lang.ini" );
    
    // Now we can use the following code no matter what $lang indicates (tr or en):
    
    echo( "<h1>{$strings[ "hello" ]}</h1><br/>{$strings[ "greeting" ]}" );
    

    One thing you should be concious of:

    • Since parse_ini_file reads a file from the file system, you must validate the value in $lang very carefully! don’t rely on user input in any way for the value of $lang as it might be malicious (link to page.php?lang=en is not good enough).
      Check the value of $lang against your own white list for example: $langs = array( "en", "tr" ); and if that fails, redirect to a general error page or something…
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multiple language website, and I use a php get variable to
I have a N2 website with 2 languages: English and Serbian. I want English
I want to display multiple languages and UI cultures on my website. I have
I have a website (Flash) localized into a dozen of languages and I want
I have one Zen Cart website in the English language. I want to make
I have a WordPress website that needs to have its articles in multiple languages.
I have a multiple language website, that uses subdirectories from the root ('/en' for
I have a website with a flag. If it is clicked, the language of
Many statically typed languages have parametric polymorphism. For example in C# one can define:
I want to test whether two languages have a string in common. Both of

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.