Example #1
0
function smartyn__($params)
{
    $original = $params['original'];
    $plural = $params['plural'];
    $n = $params['count'];
    return n__($original, $plural, $n);
}
Example #2
0
?>
</p>
	<p><?php 
echo __('This is another text (with parenthesis)');
?>
</p>
	<p><?php 
echo __('This is another text "with double quotes"');
?>
</p>
	<p><?php 
echo htmlspecialchars(__('This is another text \'with escaped quotes\''));
?>
</p>
	<p><?php 
echo n__('%s point', '%s points', rand(1, 3));
?>
</p>
	<p><?php 
echo p__('dsadasd', 'Text with prefix');
?>
</p>
	<?php 
echo foo();
?>
	<?php 
function foo()
{
    $date = time();
    $date_str_parts_arr[] = __('on :date at :clock', array(':date' => date('d.m.Y', $date), ':clock' => date('H:i', $date)));
    return $date_str_parts_arr[0];
Example #3
0
 /**
  * @depends testPoFileExtractor
  */
 public function testMultiPlural($translations)
 {
     $translator = new \Gettext\Translator();
     $translator->loadTranslations($translations);
     //Set the current translator before execute the functions
     __currentTranslator($translator);
     /**
      * Test that nplural=3 plural translation check comes up with the correct translation key.
      */
     $this->assertEquals('1 plik', n__("one file", "multiple files", 1), "plural calculation result bad");
     $this->assertEquals('2,3,4 pliki', n__("one file", "multiple files", 2), "plural calculation result bad");
     $this->assertEquals('2,3,4 pliki', n__("one file", "multiple files", 3), "plural calculation result bad");
     $this->assertEquals('2,3,4 pliki', n__("one file", "multiple files", 4), "plural calculation result bad");
     $this->assertEquals('5-21 plików', n__("one file", "multiple files", 5), "plural calculation result bad");
     $this->assertEquals('5-21 plików', n__("one file", "multiple files", 6), "plural calculation result bad");
     /**
      * Test that when less then the nplural translations are available it still works.
      */
     $this->assertEquals('1', n__("one", "more", 1), "non-plural fallback failed");
     $this->assertEquals('*', n__("one", "more", 2), "non-plural fallback failed");
     $this->assertEquals('*', n__("one", "more", 3), "non-plural fallback failed");
     /**
      * Test that non-plural translations the fallback still works.
      */
     $this->assertEquals('more', n__("single", "more", 3), "non-plural fallback failed");
 }
Example #4
0
?>
</p>
	<p><?php 
echo __('This is another text (with parenthesis)');
?>
</p>
	<p><?php 
echo __('This is another text "with double quotes"');
?>
</p>
	<p><?php 
echo htmlspecialchars(__('This is another text \'with escaped quotes\''));
?>
</p>
	<p><?php 
echo n__('%s point', '%s points', 4);
?>
</p>
	<p><?php 
echo p__('dsadasd', 'Text with prefix');
?>
</p>

	<br>	
	<script>
		var i18n = new Jed({
			// Generally output by a .po file conversion
			locale_data: <?php 
include $file_with_translationsJS;
?>
,