Witam
Potrzebuję zrobić takie tłumaczenie strony jest jest tutaj:
http://www.vbenterprisetranslator.com/
Tzn klikam w odpowiednią flage i tłumaczy mi cały kod źródłowy...
Prosze o jakieś przykłady.
plik languages/pl.php
<?php $_TEXT['SELECT_LANGUAGE'] = 'Select language'; $_TEXT['HELLO_WORLD'] = 'Hello World'; ?>
plik index.php
<?php $_TEXT['SELECT_LANGUAGE'] = 'Wybierz język'; $_TEXT['HELLO_WORLD'] = 'Witaj świecie'; ?>
<?php $lang = $_GET['lang']; } else { $lang = 'pl'; } include 'languages/' . $lang . '.php'; } else { include 'languages/pl.php'; } echo $_TEXT['SELECT_LANGUAGE'] . ': <a href="index.php?lang=pl">pl</a> | <a href="index.php?lang=en">en</a>';
<?php /** * Translating language with Google API * @author gabe@fijiwebdesign.com * @version $id$ * @license - Share-Alike 3.0 (http://creativecommons.org/licenses/by-sa/3.0/) * * Google requires attribution for their Language API, please see: <a href="http://code.google.com/apis/ajaxlanguage/documentation/#Branding" target="_blank">http://code.google.com/apis/ajaxlanguage/d...ation/#Branding</a> * */ class Google_Translate_API { /** * Translate a piece of text with the Google Translate API * @return String * @param $text String * @param $from String[optional] Original language of $text. An empty String will let google decide the language of origin * @param $to String[optional] Language to translate $text to */ function translate($text, $from = '', $to = 'en') { $url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='.rawurlencode($text).'&langpair='.rawurlencode($from.'|'.$to); $url, null, 'http'=>array( 'method'=>"GET", 'header'=>"Referer: http://".$_SERVER['HTTP_HOST']."/\r\n" ) ) ) ); return self::_unescapeUTF8EscapeSeq($matches[1]); } return false; } /** * Convert UTF-8 Escape sequences in a string to UTF-8 Bytes * @return UTF-8 String * @param $str String */ function _unescapeUTF8EscapeSeq($str) { return preg_replace_callback("/\\\u([0-9a-f]{4})/i", create_function('$matches', 'return html_entity_decode(\'&#x\'.$matches[1].\';\', ENT_NOQUOTES, \'UTF-8\');'), $str); } } // example usage $text = 'Czesc to ja.'; $trans_text = Google_Translate_API::translate($text, 'pl', 'en'); if ($trans_text !== false) { } ?>