Ejemplo n.º 1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->object = new Po();
     $testObject = json_decode(file_get_contents(TEST_ROOT . '/tests/testLangDir/test/po_good.json'));
     $fileInfo = new FileInfo();
     foreach ($testObject as $k => $v) {
         if (is_object($v)) {
             $val = [];
             foreach ($v as $k1 => $v1) {
                 $val[$k1] = $v1;
             }
         } else {
             $val = $v;
         }
         $fileInfo->{$k} = $val;
     }
     $this->testObject = $fileInfo;
     G11n::getDefault();
 }
Ejemplo n.º 2
0
/**
 * Small multilanguaging pluralisation function =;).
 *
 * @param   string   $singular    Singular form of text to translate.
 * @param   string   $plural      Plural form of text to translate.
 * @param   integer  $count       The number of items
 * @param   array    $parameters  Replacement parameters.
 *
 * @return string Translated text.
 */
function g11n4t($singular, $plural, $count, array $parameters = [])
{
    return G11n::translatePlural($singular, $plural, $count, $parameters);
}
Ejemplo n.º 3
0
 /**
  * Test method.
  *
  * @return void
  */
 public function testDebugYTranslate()
 {
     G11n::setDebug(true);
     $this->assertThat(g11n3t('Hello test'), $this->equalTo('+-HHHH-+'));
 }
Ejemplo n.º 4
0
 /**
  * Test method.
  *
  * @return void
  */
 public function testDomain3()
 {
     G11n::setCurrent('zz-ZZ');
     G11n::loadLanguage('testExtension', 'testDomain2');
     $this->assertThat(g11n3t('Hello test Z'), $this->equalTo('Hallo Test Z'));
 }
Ejemplo n.º 5
0
 /**
  * Draws untranslated strings to paste in a language file.
  *
  * @return void
  *
  * @deprecated
  */
 private static function drawDesignTable()
 {
     $items = G11n::get('processedItems');
     $file = '';
     $count = 0;
     echo '<h3>Design</h3>';
     echo '<pre style="border: 1px dashed gray; padding: 0.5em; font-size: 12px;">';
     foreach ($items as $string => $item) {
         if ($item->status != '-') {
             continue;
         }
         $f = self::JReplace($item->file);
         if ($f != $file) {
             $file = $f;
             echo '# From file: <strong>' . $f . '</strong>';
         }
         echo "\n";
         echo htmlspecialchars($string) . "\n";
         echo htmlspecialchars($string) . "\n";
         $count++;
     }
     echo '</pre>';
     echo $count ? sprintf('<h3>Found <b>%d</b> untranslated items</h3>', $count) : '<h3 style="color: green;">Everything\'s translated <tt>=:)</tt></h3>';
 }