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


PHP Utils::getRepoStrings方法代码示例

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


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

示例1: 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

示例2: foreach

<?php

namespace Transvision;

$tmx_target2 = Utils::getRepoStrings($locale2, $check['repo']);
if ($search->isPerfectMatch()) {
    $locale3_strings = preg_grep($search->getRegex(), $tmx_target2);
} else {
    $locale3_strings = $tmx_target2;
    foreach (Utils::uniqueWords($initial_search) as $word) {
        $search->setRegexSearchTerms($word);
        $locale3_strings = preg_grep($search->getRegex(), $locale3_strings);
    }
}
array_splice($locale3_strings, 200);
foreach (Project::getRepositories() as $repository) {
    $loc_list[$repository] = Project::getRepositoryLocales($repository);
    $target_locales_list2[$repository] = Utils::getHtmlSelectOptions($loc_list[$repository], $locale2);
}
开发者ID:lester-shu,项目名称:transvision,代码行数:19,代码来源:3locales_search.php

示例3: trim

$case_sensitive = $get_option('case_sensitive') ? '' : 'i';
if ($get_option('perfect_match')) {
    $regex = '~' . $whole_word . trim('^' . preg_quote($initial_search, '~') . '$') . $whole_word . '~' . $case_sensitive . 'u';
    if ($request->parameters[2] == 'entities') {
        $entities = ShowResults::searchEntities($source_strings, $regex);
        $source_strings = array_intersect_key($source_strings, array_flip($entities));
    } else {
        $source_strings = preg_grep($regex, $source_strings);
        $entities = array_keys($source_strings);
    }
} else {
    foreach (Utils::uniqueWords($initial_search) as $word) {
        $regex = '~' . $whole_word . preg_quote($word, '~') . $whole_word . '~' . $case_sensitive . 'u';
        if ($request->parameters[2] == 'entities') {
            $entities = ShowResults::searchEntities($source_strings, $regex);
            $source_strings = array_intersect_key($source_strings, array_flip($entities));
        } else {
            $source_strings = preg_grep($regex, $source_strings);
            $entities = array_keys($source_strings);
        }
    }
}
// We have our list of filtered source strings, get corresponding target locale strings
$target_strings = array_intersect_key(Utils::getRepoStrings($request->parameters[5], $request->parameters[3]), array_flip($entities));
// We sort arrays by key before array_splice() to keep matching keys
ksort($source_strings);
ksort($target_strings);
// Limit results to 200
array_splice($source_strings, 200);
array_splice($target_strings, 200);
return $json = ShowResults::getRepositorySearchResults($entities, [$source_strings, $target_strings]);
开发者ID:rohankhakurel,项目名称:transvision,代码行数:31,代码来源:repository_search.php

示例4: Search

$initial_search = Utils::cleanString($request->parameters[5]);
$terms = Utils::uniqueWords($initial_search);
// Define our regex
$search = (new Search())->setSearchTerms(Utils::cleanString($initial_search))->setRegexWholeWords($get_option('whole_word'))->setRegexCaseInsensitive($get_option('case_sensitive'))->setRegexPerfectMatch($get_option('perfect_match'));
// We loop through all repositories and merge the results
foreach ($repositories as $repository) {
    $source_strings = Utils::getRepoStrings($request->parameters[3], $repository);
    foreach ($terms as $word) {
        $search->setRegexSearchTerms($word);
        $source_strings = preg_grep($search->getRegex(), $source_strings);
    }
    /*
        If we don't have any match for a repo, no need to do heavy calculations,
        just skip to the next repo.
    */
    if (empty($source_strings)) {
        continue;
    }
    /*
        We are only interested in target strings with keys in common with our
        source strings.
    */
    $target_strings = Utils::getRepoStrings($request->parameters[4], $repository);
    foreach ($source_strings as $key => $value) {
        if (isset($target_strings[$key]) && !empty($target_strings[$key])) {
            $output[] = [$value, $target_strings[$key]];
        }
    }
    unset($source_strings, $target_strings);
}
return $json = ShowResults::getTranslationMemoryResults($output, $initial_search, $get_option('max_results'), $get_option('min_quality'));
开发者ID:hellosct1,项目名称:transvision,代码行数:31,代码来源:translation_memory.php

示例5: function

<?php

namespace Transvision;

// Set $repo to get the correct list of locales for Gaia from l10n-init.php
$repo = 'gaia';
require_once INC . 'l10n-init.php';
// Functions
$get_or_set = function ($arr, $value, $fallback) {
    return isset($_GET[$value]) && in_array($_GET[$value], $arr) ? $_GET[$value] : $fallback;
};
$get_repo_strings = function ($locale, $repo) {
    return array_filter(Utils::getRepoStrings($locale, $repo), 'strlen');
};
$build_select = function ($array_in, $selected_elm) use($repos_nice_names) {
    $string_out = '';
    foreach ($array_in as $elm) {
        $ch = $elm == $selected_elm ? ' selected' : '';
        $elm_nice_name = isset($repos_nice_names[$elm]) ? $repos_nice_names[$elm] : $elm;
        $string_out .= "<option" . $ch . " value=" . $elm . ">" . $elm_nice_name . "</option>\n";
    }
    return $string_out;
};
// Variables
// Project::getGaiaRepositories() returns ordered repos from newest to oldest
$repo1 = 'gaia';
$repo2 = Project::getLastGaiaBranch();
$locale = $get_or_set($all_locales, 'locale', $locale);
$repo1 = $get_or_set($gaia_repos, 'repo1', $repo1);
$repo2 = $get_or_set($gaia_repos, 'repo2', $repo2);
// Get the locale list
开发者ID:rohankhakurel,项目名称:transvision,代码行数:31,代码来源:gaia.php

示例6: elseif

<?php

namespace Transvision;

$strings = Utils::getRepoStrings(Project::getReferenceLocale($repo), $repo);
// Invalid entity, we don't do any calculation and get back to the view
if (!$entity) {
    return $error = 1;
} elseif (!array_key_exists($entity, $strings)) {
    return $error = 2;
}
include MODELS . 'api/entity.php';
开发者ID:lester-shu,项目名称:transvision,代码行数:12,代码来源:onestring.php

示例7:

<?php

namespace Transvision;

require_once INC . 'l10n-init.php';
$chan1 = 'aurora';
$chan2 = 'beta';
if (isset($_GET['chan1']) && in_array($_GET['chan1'], $desktop_repos)) {
    $chan1 = $_GET['chan1'];
}
if (isset($_GET['chan2']) && in_array($_GET['chan2'], $desktop_repos)) {
    $chan2 = $_GET['chan2'];
}
$strings = [];
$strings[$chan1] = Utils::getRepoStrings($locale, $chan1);
$strings[$chan2] = Utils::getRepoStrings($locale, $chan2);
$chan_selector1 = $chan_selector2 = '';
foreach ($desktop_repos as $repo) {
    $ch1 = $repo == $chan1 ? ' selected' : '';
    $ch2 = $repo == $chan2 ? ' selected' : '';
    $chan_selector1 .= "\t<option" . $ch1 . " value=" . $repo . ">" . $repos_nice_names[$repo] . "</option>\n";
    $chan_selector2 .= "\t<option" . $ch2 . " value=" . $repo . ">" . $repos_nice_names[$repo] . "</option>\n";
}
// Get the locale list
$loc_list = Project::getRepositoryLocales($repo);
// Build the target locale switcher
$target_locales_list = '';
foreach ($loc_list as $loc) {
    $ch = $loc == $locale ? ' selected' : '';
    $target_locales_list .= "\t<option" . $ch . " value=" . $loc . ">" . $loc . "</option>\n";
}
开发者ID:benoit-l,项目名称:transvision,代码行数:31,代码来源:channelcomparison.php

示例8: function

<?php

namespace Transvision;

require_once INC . 'l10n-init.php';
$strings[$repo] = Utils::getRepoStrings($locale, $repo);
$strings_english[$repo] = Utils::getRepoStrings('en-US', $repo);
$channel_selector = Utils::getHtmlSelectOptions(array_intersect_key($repos_nice_names, array_flip($desktop_repos)), $repo, true);
// Get the locale list
$loc_list = Project::getRepositoryLocales($repo);
// build the target locale switcher
$target_locales_list = Utils::getHtmlSelectOptions($loc_list, $locale);
$akeys = array_filter(array_keys($strings[$repo]), function ($entity) {
    return substr($entity, -9) == 'accesskey';
});
$ak_labels = ['.label', '.title', '.title2'];
$ak_results = [];
foreach ($akeys as $akey) {
    $entity = substr($akey, 0, -10);
    $akey_value = $strings[$repo][$akey];
    foreach ($ak_labels as $ak_label) {
        if (isset($strings[$repo][$entity . $ak_label]) && !empty($strings[$repo][$entity . $ak_label]) && isset($strings_english[$repo][$akey]) && !empty($strings_english[$repo][$akey])) {
            if ($akey_value == '') {
                $ak_results[$akey] = $entity . $ak_label;
            } elseif (mb_stripos($strings[$repo][$entity . $ak_label], $akey_value) === false) {
                $ak_results[$akey] = $entity . $ak_label;
            } else {
                break;
            }
        }
    }
开发者ID:lester-shu,项目名称:transvision,代码行数:31,代码来源:accesskeys.php

示例9: foreach

foreach ($repos as $val) {
    $ch = $val == $repo ? ' selected' : '';
    $channel_selector .= "\t<option" . $ch . " value=" . $val . ">" . $repos_nice_names[$val] . "</option>\n";
}
// Using a callback with strlen() avoids filtering out numeric strings with a value of 0
$strings['en-US'][$repo] = array_filter(Utils::getRepoStrings('en-US', $repo), 'strlen');
$gaia_locales = Project::getRepositoryLocales($repo);
// We don't want en-US in the repos
if ($key = array_search('en-US', $gaia_locales)) {
    unset($gaia_locales[$key]);
}
$string_count = [];
// Referen_ce locale count
$count_reference = count($strings['en-US'][$repo]);
foreach ($gaia_locales as $val) {
    $strings[$val][$repo] = array_filter(Utils::getRepoStrings($val, $repo), 'strlen');
    $string_count[$val] = ['total' => count($strings[$val][$repo]), 'missing' => count(array_diff_key($strings['en-US'][$repo], $strings[$val][$repo])), 'identical' => count(array_intersect_assoc($strings['en-US'][$repo], $strings[$val][$repo]))];
    unset($strings[$val][$repo]);
}
$json = [];
$table = '
<style>td {text-align:right;} form[name="searchform"] { text-align: center; }</style>
<table>
<tr>
    <th>Locale</th>
    <th>Total</th>
    <th>Missing</th>
    <th>Translated</th>
    <th>Identical</th>
    <th>Completion</th>
    <th>Status estimate</th>
开发者ID:lester-shu,项目名称:transvision,代码行数:31,代码来源:showrepos.php

示例10: 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

示例11: preg_grep

        $search->setRegexSearchTerms($word);
        $source_strings = preg_grep($search->getRegex(), $source_strings);
    }
    /*
        If we don't have any match for a repo, no need to do heavy calculations,
        just skip to the next repo.
    */
    if (empty($source_strings)) {
        continue;
    }
    /*
        We are only interested in target strings with keys in common with our
        source strings. Not sending noise to getTranslationMemoryResults() has
        a major performance and memory impact.
    */
    $target_strings = array_intersect_key(Utils::getRepoStrings($request->parameters[4], $repository), $source_strings);
    /*
        We are not interested in keeping duplicate strings that have
        different keys because this API does not take into account the
        frequency of matches but the similarity of the strings.
    */
    $target_strings = array_unique($target_strings);
    /*
       The + operator is slightly faster than array_merge and also easier
       to read. The functional difference doesn't matter in this case
       (http://stackoverflow.com/questions/7059721/array-merge-versus/27717809#27717809)
    */
    $source_strings_merged += $source_strings;
    $target_strings_merged += $target_strings;
    unset($source_strings, $target_strings);
}
开发者ID:lester-shu,项目名称:transvision,代码行数:31,代码来源:translation_memory.php


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