コード例 #1
0
 public function testImportLocalPoFile()
 {
     $po_filepath = TEST_FILES . 'gettext/test.po';
     $lang_filepath = TEST_FILES . 'gettext/test.lang';
     $obj = new _GetTextManager();
     $locale_data = _DotLangParser::parseFile($lang_filepath, false);
     $po_import = $obj->importLocalPoFile($po_filepath, $locale_data, false);
     // I should have imported data
     $this->boolean($po_import['imported'])->isTrue();
     // I should have one error
     $this->integer(count($po_import['errors']))->isEqualTo(1);
     // Test one translated string
     $this->string($po_import['strings']['Innovating <span>for you</span>'])->isEqualTo('¡Inovando <span>para ti!</span>');
     // Test one translated string in both lang and po file (second has precedence)
     $this->string($po_import['strings']['Fast, flexible, <span>secure</span>'])->isEqualTo('Rápido, flexible, seguro');
     // Empty translation in .po file, existing in .lang file
     $this->string($po_import['strings']['Empty'])->isEqualTo('test');
     // Test one identical string
     $this->string($po_import['strings']['Download'])->isEqualTo('Download {ok}');
     // Test one translation starting with ; (should be ignored)
     $this->string($po_import['strings']['Download test'])->isEqualTo('Download test');
 }
コード例 #2
0
<?php

namespace Langchecker;

use Transvision\Json;
LangManager::$error_checking = false;
DotLangParser::$extract_metadata = false;
DotLangParser::$log_errors = false;
$untranslated = [];
$translated = [];
$file_count = [];
$all_strings = [];
foreach ($mozilla as $current_locale) {
    // Initialize locale
    $untranslated[$current_locale] = 0;
    $translated[$current_locale] = 0;
    $file_count[$current_locale] = 0;
    foreach (Project::getWebsitesByDataType($sites, 'lang') as $current_website) {
        $reference_locale = Project::getReferenceLocale($current_website);
        // Ignore reference language
        if ($current_locale == $reference_locale) {
            continue;
        }
        foreach (Project::getWebsiteFiles($current_website) as $current_filename) {
            // File not supported
            if (!Project::isSupportedLocale($current_website, $current_locale, $current_filename, $langfiles_subsets)) {
                continue;
            }
            // File marked as obsolete
            if (Project::isObsoleteFile($current_website, $current_filename, $current_locale)) {
                continue;
コード例 #3
0
 public function testgetMetaTags()
 {
     $obj = new _DotLangParser();
     $this->array($obj->getMetaTags())->isEqualTo(['## NOTE:', '## TAG:', '## MAX_LENGTH:', '## URL:']);
 }