i want to develop multi language website in php. but i don't want to use a database on my server so how can i do that. language can be trancelate on the fly. is there any way ?
You can use a language file . There you can store all your labels and there values. You can have files like these : label_eng.php label_fra.php .... And have inside each file something like these : $lang['Name'] = 'Name'; $lang['Message'] = 'Message'; $lang['Subject'] = 'Subject'; You can include those lang files , and use variable.
You can apply the language to a COOKIE or a SESSION and call on it time after time. You can also use the DEFINE function in your language files.
You make them If you don't want to as your first post suggests, you could link to Google translator versions though they are terrible, might be better than nothing though.
thanks dear, i will use Google translator but if want to translate any dynamic data on the fly ( when my web site will run or some one post any comment etc. ) then i can i convert that data in to other language with the help of Google translator. ?
Go to Google's language tools, enter a page URL and language to/fro and copy the link into your code in a <a href="...">[language]</a> link. You can replace the link in the URL with the full path to the current page with $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI']
thanks For your help. but i am new in php so can you explane me. like explane me with the help of code ?
<?php $current_page = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $content_lang = 'en'; $content_lang_name = 'English'; $translations = array('es' => 'Spanish', 'fr' => 'French'); foreach ($translations as $k=>$v) { echo "<a href=\"http://translate.google.com/translate?u=" . urlencode($current_page) . "&langpair={$content_lang}%7C{$k}\">Translate from {$content_lang_name} to {$v}</a>"; } PHP:
1st of all thanks. and now can any one demonstrate this code what this code doing on each line. How to use this line :- $current_page = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; PHP:
<?php // Gets the current page URL (more or less as the user typed it in the address bar) $current_page = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; // The language of the content (code and name) $content_lang = 'en'; $content_lang_name = 'English'; // An array of all the wanted translations $translations = array('es' => 'Spanish', 'fr' => 'French'); // Loop over the translations foreach ($translations as $k=>$v) { // Build a URL to the google translator substituting the current page, // and the languages to be translated to/fro echo "<a href=\"http://translate.google.com/translate?u=" . urlencode($current_page) . "&langpair={$content_lang}%7C{$k}\">Translate from {$content_lang_name} to {$v}</a>"; } PHP:
suppose i have three link 1st:- www [dot] techinfocomp [dot] com/ 2nd :- www [dot] techinfocomp.com/about [dot] html 3rd:- www [dot] techinfocomp.com/career [dot] html now how to use this script on this website ? www.techinfocomp.com pl tell me. Thanks
Does your host support PHP? If so, copy/paste my code where you want the "translate" links. If you want to keep .html pages, then add this line to your .htaccess file: AddType application/x-httpd-php .php .htm .html
Thanks for your support. what it's mean :- If so, copy/paste my code where you want the "translate" links. yes my host support php if i want to translate hole page the what i have to do or if i just need to translate a peace of code then what i have to do ? i just need to copy past this code in the top or my web page? this code what you provide us will translate hole page ?
Copy/paste it in your web page where you want the links for translating to be displayed. It will take the user to a page translated by Google's language tools. Remember the line in the .htaccess (you may have to create this file in your web root if it doesn't exist)
sorry sir i cant able to understand what do you mean. // An array of all the wanted translations $translations = array('es' => 'Spanish', 'fr' => 'French'); PHP: how to change language with this line. pl provide me some simple example or pl simplify me this example sir.
$translations = array('es' => 'Spanish', 'fr' => 'French'); PHP: Follow the pattern: The language code in single quotes, followed by => then the language name in quotes, then a comma. Get the language code from the Google language tools page, when you translate a page, you should see &langpair with 2 codes in it. Examples: 'es' => 'Spanish', 'ko' => 'Korean', 'jp' => 'Japanese', Remember to put them inside the array( ... ) This might be an easier format: $translations = array( 'es' => 'Spanish', 'fr' => 'French', 'ko' => 'Korean', 'jp' => 'Japanese', ); PHP: