当前位置: 首页>>代码示例>>PHP>>正文


PHP Project::getReferenceLocale方法代码示例

本文整理汇总了PHP中Project::getReferenceLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::getReferenceLocale方法的具体用法?PHP Project::getReferenceLocale怎么用?PHP Project::getReferenceLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Project的用法示例。


在下文中一共展示了Project::getReferenceLocale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compareRawFiles

 /**
  * Compare reference and localized raw file
  *
  * @param array  $website  Website data
  * @param string $locale   Locale to analyze
  * @param string $filename File to analyze
  *
  * @return array Results from comparison
  */
 public static function compareRawFiles($website, $locale, $filename)
 {
     $results = [];
     // Store reference file hash and last update date
     $reference_locale = Project::getReferenceLocale($website);
     $reference_filename = Project::getLocalFilePath($website, $reference_locale, $filename);
     if (file_exists($reference_filename)) {
         $reference_content = sha1_file($reference_filename);
         $results['reference_exists'] = true;
         $results['reference_url'] = Project::getPublicFilePath($website, $reference_locale, $filename);
         $results['reference_lastupdate'] = Utils::getSVNCommitTimestamp($reference_filename);
     } else {
         $results['reference_exists'] = false;
         $results['cmp_result'] = 'missing_reference';
     }
     // Generate locale file hash and last update date
     $locale_filename = Project::getLocalFilePath($website, $locale, $filename);
     if (file_exists($locale_filename)) {
         $locale_content = sha1_file($locale_filename);
         $results['locale_exists'] = true;
         $results['locale_url'] = Project::getPublicFilePath($website, $locale, $filename);
         $results['locale_lastupdate'] = Utils::getSVNCommitTimestamp($locale_filename);
         if ($results['reference_exists']) {
             if ($locale_content == $reference_content) {
                 $results['cmp_result'] = 'untranslated';
             } elseif ($results['reference_lastupdate'] > $results['locale_lastupdate']) {
                 // I check dates only if content is not identical
                 $results['cmp_result'] = 'outdated';
             } else {
                 $results['cmp_result'] = 'ok';
             }
         }
     } else {
         $results['locale_exists'] = false;
         $results['cmp_result'] = 'missing_locale';
     }
     return $results;
 }
开发者ID:Jobava,项目名称:mirror-langchecker,代码行数:47,代码来源:RawManager.php

示例2: count

<?php

namespace Transvision;

$source = Utils::getRepoStrings(Project::getReferenceLocale($repo), $repo);
$target = Utils::getRepoStrings($locale, $repo);
// Set up channel selector, ignore mozilla.org
$channels = Project::getSupportedRepositories();
unset($channels['mozilla_org']);
$channel_selector = Utils::getHtmlSelectOptions($channels, $repo, true);
// Build the target locale switcher
$target_locales_list = Utils::getHtmlSelectOptions(Project::getRepositoryLocales($repo), $locale);
$source = array_map(['Transvision\\AnalyseStrings', 'cleanUpEntities'], $source);
$target = array_map(['Transvision\\AnalyseStrings', 'cleanUpEntities'], $target);
// We need to ignore some strings because of false positives
$ignored_strings = ['mail/chrome/messenger/aboutRights.dtd:rights.webservices-term4', 'suite/chrome/branding/aboutRights.dtd:rights.webservices-term4', 'toolkit/chrome/global/aboutRights.dtd:rights.webservices-term5'];
$var_errors = AnalyseStrings::differences($source, $target, $repo, $ignored_strings);
$error_count = count($var_errors);
// Add component filter
if (in_array($repo, $desktop_repos)) {
    // Build logic to filter components
    $javascript_include = ['component_filter.js'];
    $components = Project::getComponents(array_flip($var_errors));
    $filter_block = '';
    foreach ($components as $value) {
        $filter_block .= " <a href='#{$value}' id='{$value}' class='filter'>{$value}</a>";
    }
}
// RTL support
$direction1 = RTLSupport::getDirection($source_locale);
$direction2 = RTLSupport::getDirection($locale);
开发者ID:rohankhakurel,项目名称:transvision,代码行数:31,代码来源:check_variables.php

示例3: elseif

// Error management
if (isset($error)) {
    if ($error == 1) {
        print "<p>No entity asked for, goodbye.</p>";
    } elseif ($error == 2) {
        print "<p>Entity does not exist for this repo, goodbye.</p>";
    }
    return;
}
// We have no error, display results
$page_descr = $entity;
// Promote API view
include VIEWS . 'templates/api_promotion.php';
?>

<table>
    <tr>
        <th>Locale</th>
        <th>Translation</th>
        <th>&nbsp;</th>
    </tr>
    <?php 
$reference_locale = Project::getReferenceLocale($repo);
foreach ($translations as $locale => $translation) {
    $rtl_support = RTLSupport::isRTL($locale) ? 'dir="rtl"' : '';
    $search_link = "/?sourcelocale={$reference_locale}&locale={$locale}&repo={$repo}&search_type=entities&recherche={$entity}&perfect_match=perfect_match";
    echo "<tr id='{$locale}''>\n" . "  <th><a href='#{$locale}'>{$locale}</a></th>\n" . "  <td lang='#{$locale}' {$rtl_support} >" . Utils::secureText($translation) . "</td>\n" . "  <td><a class='onestring_search' href='{$search_link}' title='Search for the entity in this locale'>�</a></td>\n" . "</tr>\n";
}
?>
</table>
<?php 
开发者ID:jotes,项目名称:transvision,代码行数:31,代码来源:onestring.php

示例4: foreach

}
foreach ($displayed_sites as $site_index => $current_website) {
    $websitename = Project::getWebsiteName($current_website);
    $website_data_source = Project::getWebsiteDataType($current_website);
    if ($website_data_source == 'lang') {
        $table_headers = "<th>Filename</th><th>URL</th><th>Status</th><th>Translations</th><th>Strings</th><th>Words</th>";
    } else {
        $table_headers = "<th>Filename</th>\n<th>Status</th>\n\n";
    }
    $html_output .= "\n\t<h2 id='{$websitename}'><a href='#{$websitename}'>{$websitename}</a></h2>\n";
    $html_output .= "\t<table class='listpages'>\n        <thead>\n            <tr>{$table_headers}</tr>\n        </thead>\n        <tbody>\n";
    // Totals to display in the table footer
    $total_strings = $total_words = $total_files = 0;
    foreach (Project::getWebsiteFiles($current_website) as $current_filename) {
        if ($website_data_source == 'lang') {
            $reference_locale = Project::getReferenceLocale($current_website);
            $reference_data = LangManager::loadSource($current_website, $reference_locale, $current_filename);
            $get_words = function ($item) {
                return str_word_count(strip_tags($item));
            };
            $nb_words = array_sum(array_map($get_words, $reference_data['strings']));
            $nb_strings = count($reference_data['strings']);
            $total_strings += $nb_strings;
            $total_words += $nb_words;
            $total_files++;
            $html_output .= "<tr>\n";
            // Check if the file is obsolete for all locales
            if (Project::isObsoleteFile($current_website, $current_filename, 'all')) {
                $html_output .= "  <td class='obsolete' title='Obsolete file'>{$current_filename}</td>\n";
            } else {
                $html_output .= "  <td>{$current_filename}</td>\n";
开发者ID:Jobava,项目名称:mirror-langchecker,代码行数:31,代码来源:listpages.inc.php

示例5: foreach

<?php

namespace Transvision;

$missing_repos = $available_repos = $results = '';
$missing_repos_count = $repos_count = 0;
$strings = ['en-US' => [], $locale => []];
foreach ($repos as $repo) {
    if (isset($_GET[$repo])) {
        $cache_file_english = Utils::getRepoStrings(Project::getReferenceLocale($repo), $repo);
        if ($cache_file_english) {
            $cache_file_locale = Utils::getRepoStrings($locale, $repo);
            if ($repo == 'mozilla_org') {
                $cache_file_locale = array_map(function ($e) {
                    return trim(rtrim($e, '{ok}'));
                }, $cache_file_locale);
            }
            // If a repo is missing, we don't have additional keys
            if ($cache_file_locale) {
                $strings['en-US'] = array_merge($strings['en-US'], $cache_file_english);
                $strings[$locale] = array_merge($strings[$locale], $cache_file_locale);
                $repos_count++;
                $available_repos .= '<br>' . $repos_nice_names[$repo] . ' (' . $locale . ')';
                unset($cache_file_locale);
            } else {
                $missing_repos_count++;
                $missing_repos .= '<br>' . $repos_nice_names[$repo] . ' (' . $locale . ')';
            }
            unset($cache_file_english);
        }
    }
开发者ID:lester-shu,项目名称:transvision,代码行数:31,代码来源:tmx_downloading.php

示例6: loadSource

 /**
  * Load file, remove empty lines and return an array of strings
  *
  * @param array  $website  Website data
  * @param string $locale   Locale to analyze
  * @param string $filename File to analyze
  *
  * @return array Data parsed from lang file
  */
 public static function loadSource($website, $locale, $filename)
 {
     $is_reference_language = $locale == Project::getReferenceLocale($website);
     $path = Project::getLocalFilePath($website, $locale, $filename);
     return DotLangParser::parseFile($path, $is_reference_language);
 }
开发者ID:Jobava,项目名称:mirror-langchecker,代码行数:15,代码来源:LangManager.php

示例7: function

namespace Transvision;

// Redirect old JSON API calls to new API
if (isset($_GET['json'])) {
    // Define sane fallback values to redirect old API calls to new API calls
    $get_value = function ($value, $fallback) {
        if (isset($_GET[$value])) {
            // 'strings_entities' search is now called 'all' in new API
            return $_GET[$value] == 'strings_entities' ? 'all' : Utils::secureText($_GET[$value]);
        }
        return $fallback;
    };
    $repo = $get_value('repo', 'release');
    $type = $get_value('search_type', 'strings');
    $source = $get_value('sourcelocale', Project::getReferenceLocale($repo));
    $target = $get_value('locale', 'fr');
    /*
       We need to urlencode() twice because Apache doesn't allow urls with
       escaped slashes, it gives a 404 instead of going through mod_rewrite
       see: http://www.leakon.com/archives/865
    */
    $terms = urlencode(urlencode(Utils::cleanString($_GET['recherche'])));
    $regex = [];
    $regex['whole'] = isset($_GET['whole_word']) ? 'whole_word=1' : '';
    $regex['case'] = isset($_GET['case_sensitive']) ? 'case_sensitive=1' : '';
    $regex['perfect'] = isset($_GET['perfect_match']) ? 'perfect_match=1' : '';
    $regex = array_filter($regex);
    $regex = count($regex) > 0 ? '?' . implode('&', $regex) : '';
    header('Status: 301 Moved Permanently', false, 301);
    header('Location:' . APP_SCHEME . "{$_SERVER['HTTP_HOST']}/api/v1/search/" . "{$type}/{$repo}/{$source}/{$target}/{$terms}/{$regex}");
开发者ID:lester-shu,项目名称:transvision,代码行数:30,代码来源:mainsearch.php


注:本文中的Project::getReferenceLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。