Jump to content

converting pages to another language


L

Recommended Posts

hey,

i was wondering if it were possible to convert english into another language with php...

For example, the google translator pages...except i want to do this with my own pages and not using their apps

My purpose is to provide little flags at the footer, and when a user clicks their flag the page is translated to the language...for example...one clicks a japanese flag so the page makes the English to japanese

thank your for your time

~L

Link to comment
Share on other sites

You can't translate from one language to another directly.  The way that other sites have multiple languages is by providing a "language file" that contains variables for each text display, then depending on which language file is included, it sets those variables to the language, which is then displayed.

Link to comment
Share on other sites

so do u mean they have phrases = to variables?

so like in the language file they would have

the = $the;

he = $he;

I = $i

but then in each other language file the same variables are set to the language

like

watashi = $i;

if the jap link is clicked...

 

then it would replace all the "I"s with "watashi"s?

 

-Thank you for your help

~L

Link to comment
Share on other sites

More like strings, rather than individual words or characters....

 

//english lanugage file
$page_title = "This site's name";
$welcome = "Welcome to our site!!";
$goodbye = "Thanks for visiting!!";

//gibberish language file
$page_title = "alksdjffweiu laksjfd a";
$welcome = "alksjdf oiweurn ba";
$goodbye = "lawieurw ksnwopiu";

 

Your php file:

 

<?php include("./languages/english.lang.php"); //or gibberish.lang.php, etc ?>
<html>
<head>
<title><?php echo $page_title; ?><?title>
</head>
<body>
<?php echo $welcome; ?>
Blah
<?php echo $goodbye; ?>
</body>
</html>

Link to comment
Share on other sites

sweet, that's pretty cool...i modified it so it includes the language clicked on like this

<?php 
if ($_GET['language'] == 'jap') {
require("japanese.php");
}
else {
require("english.php");
}
?>

it works good...but do u know how i can display the actual charecters?...because when i just paste it as the japanese charecters it shows up as ??...is this php or does this have to do with my operating system?

 

Thank you for your time

~L

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.