コード例 #1
0
function smarty_function_breadcrumbs($params, $smarty)
{
    global $prefs;
    extract($params);
    if (empty($crumbs)) {
        trigger_error("assign: missing 'crumbs' parameter");
        return;
    }
    if (empty($loc)) {
        trigger_error("assign: missing 'loc' parameter");
        return;
    }
    if ($type === 'pagetitle' && $prefs['site_title_breadcrumb'] === 'y') {
        $type = 'desc';
    }
    $text_to_display = '';
    switch ($type) {
        case 'invertfull':
            $text_to_display = breadcrumb_buildHeadTitle(array_reverse($crumbs));
            break;
        case 'fulltrail':
            $text_to_display = breadcrumb_buildHeadTitle($crumbs);
            break;
        case 'pagetitle':
            $text_to_display = breadcrumb_getTitle($crumbs, $loc);
            break;
        case 'desc':
            $text_to_display = breadcrumb_getDescription($crumbs, $loc);
            break;
        case 'trail':
        default:
            $text_to_display = breadcrumb_buildTrail($crumbs, $loc);
            break;
    }
    if (!empty($machine_translate)) {
        require_once 'lib/core/Multilingual/MachineTranslation/GoogleTranslateWrapper.php';
        $translator = new Multilingual_MachineTranslation_GoogleTranslateWrapper($source_lang, $target_lang);
        $text_to_display = $translator->translateText($text_to_display);
    }
    print $text_to_display;
}
コード例 #2
0
function translate_text($text, $sourceLang, $targetLang, $html = true)
{
	require_once('lib/core/Multilingual/MachineTranslation/GoogleTranslateWrapper.php');
	$translator = new Multilingual_MachineTranslation_GoogleTranslateWrapper($sourceLang, $targetLang, $html);
	$translatedText = $translator->translateText($text);
	return $translatedText;	

}
コード例 #3
0
 /**
  * @group multilingual
  */
 public function test_english_titles_get_translated()
 {
     $this->markTestSkipped('Google Translation API returning empty translations.');
     $text = '<h3 class="showhide_heading" id="Get_Started_using_Profiles"><a class="wiki"  href="tiki-admin.php?profile=&amp;category=Featured+profiles&amp;repository=http%3a%2f%2fprofiles.tiki.org%2fprofiles&amp;preloadlist=y&amp;page=profiles&amp;list=List#profile-results" rel="">Get Started using Admin Panel</a><br /></h3><h3 class="showhide_heading" id="Get_Started_using_Profiles"><a class="wiki"  href="tiki-admin.php?profile=&amp;category=Featured+profiles&amp;repository=http%3a%2f%2fprofiles.tiki.org%2fprofiles&amp;preloadlist=y&amp;page=profiles&amp;list=List#profile-results" rel="">Get Started using Profiles</a><br /></h3>';
     $translator = new Multilingual_MachineTranslation_GoogleTranslateWrapper('en', 'fr');
     $translation = $translator->translateText($text);
     $this->assertEquals('<h3 class="showhide_heading" id="Get_Started_using_Profiles"><a class="wiki"  href="tiki-admin.php?profile=&amp;category=Featured+profiles&amp;repository=http%3a%2f%2fprofiles.tiki.org%2fprofiles&amp;preloadlist=y&amp;page=profiles&amp;list=List#profile-results" rel="">commencer à utiliser le panneau admin</a><br /></h3><h3 class="showhide_heading" id="Get_Started_using_Profiles"><a class="wiki"  href="tiki-admin.php?profile=&amp;category=Featured+profiles&amp;repository=http%3a%2f%2fprofiles.tiki.org%2fprofiles&amp;preloadlist=y&amp;page=profiles&amp;list=List#profile-results" rel="">commencer à utiliser les profils</a><br /></h3>', $translation, "The translation was not correct for text: {$text}.");
 }
コード例 #4
0
ファイル: renderlib.php プロジェクト: railfuture/tiki-website
	private function setupMultilingual() // {{{
	{
		global $prefs;

		if ($prefs['feature_multilingual'] != 'y')
			return;

		$tikilib = TikiLib::lib('tiki');
		$multilinguallib = TikiLib::lib('multilingual');
		
		if ( !empty($this->info['lang'])) { 
			$this->trads = $multilinguallib->getTranslations('wiki page', $this->info['page_id'], $this->page, $this->info['lang']);
			$this->smartyassign('trads', $this->trads);
			$this->smartyassign('translationsCount', count($this->trads));
			$pageLang = $this->info['lang'];
			$this->smartyassign('pageLang', $pageLang);
		}
		
		if ($prefs['feature_machine_translation'] == 'y' && !empty($this->info['lang'])) {
			require_once('lib/core/Multilingual/MachineTranslation/GoogleTranslateWrapper.php');
			$translator = new Multilingual_MachineTranslation_GoogleTranslateWrapper($this->info['lang'], $this->info['lang']);
			$langsCandidatesForMachineTranslation = $translator->getLangsCandidatesForMachineTranslation($this->trads);
			$this->smartyassign('langsCandidatesForMachineTranslation', $langsCandidatesForMachineTranslation);
		}
				
		$bits = $multilinguallib->getMissingTranslationBits('wiki page', $this->info['page_id'], 'critical', true);
		
		$alertData = array();
		foreach ( $bits as $translationBit ) {
			$alertData[] = $multilinguallib->getTranslationsWithBit($translationBit, $this->info['page_id']);
		}

		$this->smartyassign('translation_alert', $alertData);
	} // }}}