Language Translation (For your site)

Started on the old forum in July 2012 · view the original in the archive · old links redirect here

1 reply · 586 views · started 14 years ago · 1 min read

2 participants
kiss Senior · 294 posts #1
  1. Create new file, name it test.php and add this code:
<?php
 if ( isset( $_SERVER["HTTP_ACCEPT_ENCODING"] ) && substr_count( $_SERVER["HTTP_ACCEPT_ENCODING"], "gzip" ) ) ob_start( "ob_gzhandler" ) ;
 else  ob_start() ;
 session_start() ;
 $lang = $_GET["lang"] ;
 if ( isset( $lang ) ) {
  setcookie( "language", $lang, time() - 1800, "/", ".YourSite.Com", 0 ) ;
  setcookie( "language", $lang, time() + 1800, "/", ".YourSite.Com", 0 ) ;
 } else {
  if ( isset( $_COOKIE["language"] ) ) {
   $lang = $_COOKIE["language"] ;
   setcookie( "language", $lang, time() - 1800, "/", ".YourSite.Com", 0 ) ;
   setcookie( "language", $lang, time() + 1800, "/", ".YourSite.Com", 0 ) ;
  } else {
   $lang = substr( $_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2 ) ;
   setcookie( "language", $lang, time() + 1800, "/", ".YourSite.Com", 0 ) ;
  }
 }
 include ( "./lang/test.php" ) ;
 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" ;
 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" ;
 echo "<head>\n" ;
 echo "<title>" . $test_title . "</title>\n" ;
 echo "<meta name=\"description\" content=\"" . $test_description . "\"/>\n" ;
 echo "<meta name=\"keywords\" content=\"" . $test_keywords . "\"/>\n" ;
 echo "</head>\n" ;
 echo "<body>\n" ;
 echo "<center>\n" ;
 echo $test_choose . "\n" ;
 echo "<br/>\n" ;
 if ( $lang == "ro" ) {
  echo "Ro | <a href=\"?lang=en\">En</a>\n" ;
 } else
  if ( $lang == "en" ) {
   echo "<a href=\"?lang=ro\">Ro</a> | En\n" ;
  }
 echo "</center>\n" ;
 echo "</body>\n" ;
 echo "</html>\n" ;
 ob_end_flush() ;
?>
  1. Create new directory, with name lang (permission 777) then create inside a file test.php and add this code:
<?php
 if ( $lang == "en" ) {
  $test_title = "Title of page" ;
  $test_description = "Describe the page" ;
  $test_keywords = "Keywords of page" ;
  $test_choose = "Choose language:" ;
 } else {
  $test_title = "Titlul paginii" ;
  $test_description = "Descrierea paginii" ;
  $test_keywords = "Cuvintele cheie ale paginii" ;
  $test_choose = "Alege limba:" ;
 }
?>
  1. This code it copied from InBuzunar.Mobi - Internetul mai aproape de tine, acum si pe mobil but i'm not using anymore. Good luck 🙂

www.inbuzunar.mobi -Your mobile portal pocket

swat Newbie · 4 posts #2

please make it in zip so that i download this in my ph0ne..tnx

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close