Jump to content

Language - How To


logicopinion

Recommended Posts

Hello, I am Realy Newbie In PHP and also i am new user here on phpfreaks.

i was helped several times here, and now i have one more question about php - how to.

 

 

i want to build simple page with several languages, but i have no idea how can i use (index.php?page=mypage&lang_id=en) such function,

how can i do it (Lang_id=somelanguage)

 

need some simple example if there is one.

 

 

thanks a lot.

 

Link to comment
Share on other sites

it is somethng different, i want other thing.

 

EXACTLY:  i want to know how does it change language when i switch from one language to another, where are that words stored and how are they read by php.

 

 

(i am realy newbie in php) and most code in above URL u provided is bounch of "ABRA CADABRA" for me.

 

 

Link to comment
Share on other sites

Well that code in that other post is one process that can be used to detemine which language to show the user. Once you know what language to show, then you need to come up with a process of getting the text.

 

Basically you need to break down all text on a page into logical protions. Then create a library of the diffeerent text for the languages.

 

Here is one example:

 

Assume you have a page with two links "Home" and "Details". Also on the page is a welcome message stating "Hello, welcome to my site". You would then need three variables for that text.

 

So, you could create different language files that define those variables:

 

File: english.php

<?php
define ('_HOME_LINK_', 'Home');
define ('_DETAILS_LINK_', 'Details');
define ('_WELCOME_', 'Hello, welcome to my site');
?>

 

File: spanish.php

<?php
define ('_HOME_LINK_', 'Casero');
define ('_DETAILS_LINK_', 'detalles');
define ('_WELCOME_', 'Hola, recepción a mi sitio');
?>

 

Then in your actual page you will select the file to use based upon the selected language (using a script such as I posted in the other thread). Then use those when you build the page:

 

<?php

//Determine the language
$language = determineLanguageFuntion();

//Include the appropriate language file to create the text variables
include($language.'.php');

//Create the home link
echo '<a href="home.php">._HOME_LINK_.</a>';

//Create the details link
echo '<a href="details.php">._DETAILS_LINK_.</a>';

//Create the welcome message
echo _WELCOME_;
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.