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
https://forums.phpfreaks.com/topic/62544-converting-pages-to-another-language/
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.

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

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>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.