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


PHP Translations::merge_with方法代码示例

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


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

示例1: array

 function test_digit_and_merge()
 {
     $entry_digit_1 = new Translation_Entry(array('singular' => 1, 'translations' => array('1')));
     $entry_digit_2 = new Translation_Entry(array('singular' => 2, 'translations' => array('2')));
     $domain = new Translations();
     $domain->add_entry($entry_digit_1);
     $domain->add_entry($entry_digit_2);
     $dummy_translation = new Translations();
     $this->assertEquals('1', $domain->translate('1'));
     $domain->merge_with($dummy_translation);
     $this->assertEquals('1', $domain->translate('1'));
 }
开发者ID:pedro-mendonca,项目名称:GlotPress-WP,代码行数:12,代码来源:test_translations.php

示例2: Translations

 function test_translations_merge()
 {
     $host = new Translations();
     $host->add_entry(new Translation_Entry(array('singular' => 'pink')));
     $host->add_entry(new Translation_Entry(array('singular' => 'green')));
     $guest = new Translations();
     $guest->add_entry(new Translation_Entry(array('singular' => 'green')));
     $guest->add_entry(new Translation_Entry(array('singular' => 'red')));
     $host->merge_with($guest);
     $this->assertEquals(3, count($host->entries));
     $this->assertEquals(array(), array_diff(array('pink', 'green', 'red'), array_keys($host->entries)));
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:12,代码来源:mo.php

示例3: format_plural

/**
 * Format a string containing a count of items.
 *
 * This function ensures that the string is pluralized correctly. Since t() is
 * called by this function, make sure not to pass already-localized strings to
 * it.
 *
 * For example:
 * @code
 *   $output = format_plural($node->comment_count, '1 comment', '@count comments');
 * @endcode
 *
 * Example with additional replacements:
 * @code
 *   $output = format_plural($update_count,
 *     'Changed the content type of 1 post from %old-type to %new-type.',
 *     'Changed the content type of @count posts from %old-type to %new-type.',
 *     array('%old-type' => $info->old_type, '%new-type' => $info->new_type)));
 * @endcode
 *
 * @param $count
 *   The item count to display.
 * @param $singular
 *   The string for the singular case. Please make sure it is clear this is
 *   singular, to ease translation (e.g. use "1 new comment" instead of "1 new").
 *   Do not use @count in the singular string.
 * @param $plural
 *   The string for the plural case. Please make sure it is clear this is plural,
 *   to ease translation. Use @count in place of the item count, as in "@count
 *   new comments".
 * @param $args
 *   An associative array of replacements to make after translation. Incidences
 *   of any key in this array are replaced with the corresponding value.
 *   Based on the first character of the key, the value is escaped and/or themed:
 *    - !variable: inserted as is
 *    - @variable: escape plain text to HTML (check_plain)
 *    - %variable: escape text and theme as a placeholder for user-submitted
 *      content (check_plain + theme_placeholder)
 *   Note that you do not need to include @count in this array.
 *   This replacement is done automatically for the plural case.
 * @param $langcode
 *   Optional language code to translate to a language other than
 *   what is used to display the page.
 * @return
 *   A translated string.
 */
function format_plural($count, $singular, $plural, $args = array(), $langcode = NULL, $context = NULL)
{
    global $language, $cfg;
    $args['@count'] = $count;
    if ($count == 1) {
        return _t($singular, $args, $langcode);
    }
    $po = new Translations();
    $po->merge_with($language['translate']);
    // Get the plural index through the gettext formula.
    $plural = $po->translate_plural($singular, $plural, $count, $context);
    return _t($plural, $args, $langcode);
}
开发者ID:renatoinnocenti,项目名称:ModulosZend,代码行数:59,代码来源:fnc.Globals.php


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