本文整理汇总了PHP中get_translations_for_domain函数的典型用法代码示例。如果您正苦于以下问题:PHP get_translations_for_domain函数的具体用法?PHP get_translations_for_domain怎么用?PHP get_translations_for_domain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_translations_for_domain函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: filter_gettext
public static function filter_gettext($translation, $text, $domain)
{
if ($text == 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction.') {
$translations = get_translations_for_domain('wc-maksuturva');
return $translations->translate($text);
}
return $translation;
}
开发者ID:jyrkih,项目名称:woocommerce_payment_module,代码行数:8,代码来源:WC_Gateway_Maksuturva_Class.php
示例2: qtranxf_translate
/**
* Looks up a translation in domain 'qtranslate', and if it is not there, uses the default WordPress domain to translate.
* @since 3.4.5.5
*/
function qtranxf_translate($s)
{
$t = get_translations_for_domain('qtranslate');
if (isset($t->entries[$s]) && !empty($t->entries[$s]->translations)) {
return $t->entries[$s]->translations[0];
}
return qtranxf_translate_wp($s);
}
开发者ID:antigenius,项目名称:qtranslate-x,代码行数:12,代码来源:qtranslate_utils.php
示例3: test_is_textdomain_loaded_for_no_translations
/**
* @ticket 21319
*/
function test_is_textdomain_loaded_for_no_translations()
{
$this->assertFalse(load_textdomain('wp-tests-domain', DIR_TESTDATA . '/non-existent-file'));
$this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
$this->assertInstanceOf('NOOP_Translations', get_translations_for_domain('wp-tests-domain'));
// Ensure that we don't confuse NOOP_Translations to be a loaded text domain.
$this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
$this->assertFalse(unload_textdomain('wp-tests-domain'));
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:l10n.php
示例4: test_get_translations_for_domain_does_not_return_null_if_override_load_textdomain_is_used
/**
* @ticket 341142
*/
public function test_get_translations_for_domain_does_not_return_null_if_override_load_textdomain_is_used()
{
add_filter('locale', array($this, 'filter_set_locale_to_german'));
add_filter('override_load_textdomain', '__return_true');
$translations = get_translations_for_domain('internationalized-plugin');
remove_filter('override_load_textdomain', '__return_true');
remove_filter('locale', array($this, 'filter_set_locale_to_german'));
$this->assertTrue($translations instanceof NOOP_Translations);
}
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:12,代码来源:loadTextdomainJustInTime.php
示例5: test_override_core_strings
/**
* @covers \Pressbooks\L10n\override_core_strings
*/
public function test_override_core_strings()
{
$text = 'My Sites';
$domain = 'default';
$translations = get_translations_for_domain($domain)->translate($text);
$translated = \Pressbooks\L10n\override_core_strings($translations, $text, $domain);
$this->assertNotEmpty($translated);
$this->assertNotEquals($text, $translated);
// 'My Sites' should be 'My Books', 'Mes Livres', ...
}
开发者ID:pressbooks,项目名称:pressbooks,代码行数:13,代码来源:test-l10n.php
示例6: override_core_strings
/**
* Change core WordPress strings.
*
* @param $translated
* @param $original
* @param $domain
*
* @return mixed
*/
function override_core_strings($translated, $original, $domain)
{
// var_dump( array( $translated, $original, $domain) );
$overrides = include_core_overrides();
if (isset($overrides[$original])) {
$translations = get_translations_for_domain($domain);
$translated = $translations->translate($overrides[$original]);
}
return $translated;
}
开发者ID:jflowers45,项目名称:pressbooks,代码行数:19,代码来源:pb-l10n.php
示例7: filters
public function filters()
{
$this->labels = array('singular' => listify_theme_mod('label-singular'), 'plural' => listify_theme_mod('label-plural'));
/* print_r( $this->labels ); */
$this->strings = $this->get_strings();
$this->domains = apply_filters('listify_gettext_domains', array('listify', 'wp-job-manager', 'wp-job-manager-tags', 'wp-job-manager-alerts', 'wp-job-manager-locations', 'wp-job-manager-wc-paid-listings', 'wp-job-manager-simple-paid-listings'));
$this->translations = get_translations_for_domain('listify');
add_filter('gettext', array($this, 'gettext'), 0, 3);
add_filter('gettext_with_context', array($this, 'gettext_with_context'), 0, 4);
add_filter('ngettext', array($this, 'ngettext'), 0, 5);
}
开发者ID:abdullahrahim,项目名称:shadighar,代码行数:11,代码来源:class-strings.php
示例8: single_meta
function single_meta($translation, $text, $domain) {
$translations = &get_translations_for_domain( $domain );
// With Tags
if ( $text == 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>. Follow any comments here with the <a href="%5$s" title="Comments RSS to %4$s" rel="alternate" type="application/rss+xml">RSS feed for this post</a>.' ) {
return $translations->translate( 'This entry was posted in %1$s and tagged %2$s. It can always be found at <a href="%3$s" title="Permalink to %4$s" rel="bookmark">it\'s permalink</a>. Follow any comments left here with the <a href="%5$s" title="Comments RSS to %4$s" rel="alternate" type="application/rss+xml">RSS feed for this post</a>.' );
}
//Without
elseif( $text == 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>. Follow any comments here with the <a href="%5$s" title="Comments RSS to %4$s" rel="alternate" type="application/rss+xml">RSS feed for this post</a>.' ) {
return $translations->translate( 'This entry was posted in %1$s. It can always be found at <a href="%3$s" title="Permalink to %4$s" rel="bookmark">it\'s permalink</a>. Follow any comments left here with the <a href="%5$s" title="Comments RSS to %4$s" rel="alternate" type="application/rss+xml">RSS feed for this post</a>.' );
}
return $translation;
}
开发者ID:rawwebdesign,项目名称:thirtyten,代码行数:13,代码来源:text-wrangler.php
示例9: qpub_filter_gettext
function qpub_filter_gettext($translated, $original, $domain)
{
// Get text from options page
$new_text = get_option('qpub_change_draft', false);
// Array of strings to be replaced
$strings = array('Draft' => $new_text ? $new_text : '');
// Replace string's translation
if (!empty($strings[$original])) {
$translations =& get_translations_for_domain($domain);
$translated = $translations->translate($strings[$original]);
}
return $translated;
}
开发者ID:steveholgado,项目名称:quick-publish,代码行数:13,代码来源:quick-publish.php
示例10: change_picture_translation
/**
* This filter translates string before it is displayed
* specifically for the words 'Use as featured image' with 'Use as Product Thumbnail' when the user is selecting a Product Thumbnail
* using media gallery.
*
* @param $translation The current translation
* @param $text The text being translated
* @param $domain The domain for the translation
*
* @return string The translated / filtered text.
*/
public static function change_picture_translation($translation, $text, $domain = 'wpshop')
{
if ($text == 'Use as featured image' && isset($_REQUEST['post_id'])) {
$post = get_post($_REQUEST['post_id']);
if (!empty($post->post_type) && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) {
return $translation;
}
$translations = get_translations_for_domain($domain);
if (empty($translations->entries['Use as product thumbnail']->translations[0])) {
return $translation;
}
return $translations->entries['Use as product thumbnail']->translations[0];
}
return $translation;
}
开发者ID:pronoSoupe,项目名称:pronobo_soupe,代码行数:26,代码来源:documents.class.php
示例11: gettext
function gettext($translation, $text, $domain)
{
global $post;
$screen = get_current_screen();
if (isset($post->post_type) && $this->is_plugin_post_type()) {
$translations = get_translations_for_domain($domain);
if ($text == 'Publish') {
return $translations->translate('Create');
}
if ($text == 'Move to Trash') {
return $translations->translate('Delete');
}
}
return $translation;
}
开发者ID:emaxees,项目名称:elpandecadadia,代码行数:15,代码来源:um-admin-functions.php
示例12: comment_says_text
function comment_says_text($translation, $text, $domain)
{
$new_says = '';
//whatever you want to have instead of 'says' in comments
$translations =& get_translations_for_domain($domain);
if ($text == '<cite class="fn">%s</cite> <span class="says">says:</span>') {
if ($new_says) {
$new_says = ' ' . $new_says;
}
//compensate for the space character
return $translations->translate('<cite class="fn">%s</cite>');
} else {
return $translation;
// standard text
}
}
开发者ID:wab,项目名称:domexblog,代码行数:16,代码来源:functions.php
示例13: translation_mangler2
function translation_mangler2($translation, $text, $domain)
{
global $post;
if ($post->post_type == 'videos') {
$translations =& get_translations_for_domain($domain);
if ($text == 'Scheduled for: <b>%1$s</b>') {
return $translations->translate('Video Date: <b>%1$s</b>');
}
if ($text == 'Published on: <b>%1$s</b>') {
return $translations->translate('Video Date: <b>%1$s</b>');
}
if ($text == 'Publish <b>immediately</b>') {
return $translations->translate('Video Date: <b>%1$s</b>');
}
}
return $translation;
}
开发者ID:staydecent,项目名称:wp-sourdough,代码行数:17,代码来源:video.php
示例14: dh_ptp_custom_rewrites
function dh_ptp_custom_rewrites($translation, $text, $domain)
{
global $post;
if (!isset($post->post_type)) {
return $translation;
}
$translations = get_translations_for_domain($domain);
$translation_array = array();
switch ($post->post_type) {
case 'easy-pricing-table':
// enter your post type name here
$translation_array = array('Enter title here' => 'Enter pricing table name here');
break;
}
if (array_key_exists($text, $translation_array)) {
return $translations->translate($translation_array[$text]);
}
return $translation;
}
开发者ID:SelaInc,项目名称:eassignment,代码行数:19,代码来源:post-types.php
示例15: translate
/**
* @param $string
*
* @return string
*/
public function translate($string)
{
$args = func_get_args();
$translated = $string;
$entry = new Translation_Entry();
$entry->singular = $string;
$entry->context = null;
foreach ($this->domains as $domain) {
/** @var $translator Translations */
$translator =& get_translations_for_domain($domain);
$translation = $translator->translate_entry($entry);
if ($translation && !empty($translation->translations)) {
$translated = $translation->translations[0];
$translated = apply_filters('gettext', $translated, $string, $domain);
break;
}
}
return $translated;
}
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:24,代码来源:Wordpress.php
示例16: hybrid_translate_plural
/**
* Helper function for allowing the theme to translate the plural text strings for both Hybrid Core and
* the available framework extensions.
*
* @since 1.6.0
* @access public
* @param string $domain
* @param string $single
* @param string $plural
* @param int $number
* @param string $context
* @return string
*/
function hybrid_translate_plural($domain, $single, $plural, $number, $context = null)
{
$translations = get_translations_for_domain($domain);
return $translations->translate_plural($single, $plural, $number, $context);
}
开发者ID:RA2WP,项目名称:RA2WP,代码行数:18,代码来源:i18n.php
示例17: _nx
/**
* A hybrid of _n() and _x(). It supports contexts and plurals.
*
* @see _n()
* @see _x()
*
*/
function _nx($single, $plural, $number, $context, $domain = 'default')
{
$translations =& get_translations_for_domain($domain);
$translation = $translations->translate_plural($single, $plural, $number, $context);
return apply_filters('ngettext_with_context', $translation, $single, $plural, $number, $context, $domain);
}
开发者ID:laiello,项目名称:cartonbank,代码行数:13,代码来源:l10n.php
示例18: _nx
/**
* Translates and retrieves the singular or plural form based on the supplied number, with gettext context.
*
* This is a hybrid of _n() and _x(). It supports context and plurals.
*
* Used when you want to use the appropriate form of a string with context based on whether a
* number is singular or plural.
*
* Example:
*
* $people = sprintf( _n( '%s person', '%s people', $count, 'context', 'text-domain' ), number_format_i18n( $count ) );
*
* @since 2.8.0
*
* @param string $single The text to be used if the number is singular.
* @param string $plural The text to be used if the number is plural.
* @param int $number The number to compare against to use either the singular or plural form.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* Default 'default'.
* @return string The translated singular or plural form.
*/
function _nx($single, $plural, $number, $context, $domain = 'default')
{
$translations = get_translations_for_domain($domain);
$translation = $translations->translate_plural($single, $plural, $number, $context);
/**
* Filter the singular or plural form of a string with gettext context.
*
* @since 2.8.0
*
* @param string $translation Translated text.
* @param string $single The text to be used if the number is singular.
* @param string $plural The text to be used if the number is plural.
* @param string $number The number to compare against to use either the singular or plural form.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
return apply_filters('ngettext_with_context', $translation, $single, $plural, $number, $context, $domain);
}
开发者ID:s4mobile,项目名称:WordPressTech,代码行数:40,代码来源:l10n.php
示例19: hybrid_extensions_gettext
/**
* Filters 'gettext' to change the translations used for the each of the extensions' textdomains. This filter
* makes it possible for the theme's MO file to translate the framework's extensions.
*
* @since 1.3.0
* @access private
* @param string $translated The translated text.
* @param string $text The original, untranslated text.
* @param string $domain The textdomain for the text.
* @return string $translated
*/
function hybrid_extensions_gettext($translated, $text, $domain)
{
/* Check if the current textdomain matches one of the framework extensions. */
if (in_array($domain, array('breadcrumb-trail', 'custom-field-series', 'post-stylesheets', 'theme-layouts'))) {
/* If the theme supports the extension, switch the translations. */
if (current_theme_supports($domain)) {
/* If the framework mofile is loaded, use its translations. */
if (hybrid_is_textdomain_loaded('hybrid-core')) {
$translations =& get_translations_for_domain('hybrid-core');
} elseif (hybrid_is_textdomain_loaded(hybrid_get_parent_textdomain())) {
$translations =& get_translations_for_domain(hybrid_get_parent_textdomain());
}
/* If translations were found, translate the text. */
if (!empty($translations)) {
$translated = $translations->translate($text);
}
}
}
return $translated;
}
开发者ID:JerryXie96,项目名称:PBSMUNC2013WebSite,代码行数:31,代码来源:i18n.php
示例20: qtranxf_getLanguageName
/**
* @since 3.4.5.4 - return language name in active language, if available, otherwise the name in native language.
*/
function qtranxf_getLanguageName($lang = '', $locale = null, $native_name = null)
{
global $q_config, $l10n;
if (empty($lang)) {
return $q_config['language_name'][$q_config['language']];
}
if (isset($q_config['language-names'][$lang])) {
return $q_config['language-names'][$lang];
}
if (!isset($l10n['language-names'])) {
//is not loaded by default, since this place should not be hit frequently
$loc = $q_config['locale'][$q_config['language']];
if (!load_textdomain('language-names', QTRANSLATE_DIR . '/lang/language-names/language-' . $loc . '.mo')) {
if ($loc[2] == '_') {
$loc = substr($loc, 0, 2);
load_textdomain('language-names', QTRANSLATE_DIR . '/lang/language-names/language-' . $loc . '.mo');
}
}
}
$translations = get_translations_for_domain('language-names');
if (!$locale) {
$locale = $q_config['locale'][$lang];
}
while (!isset($translations->entries[$locale])) {
if ($locale[2] == '_') {
$locale = substr($locale, 0, 2);
if (isset($translations->entries[$locale])) {
break;
}
}
if (!$native_name) {
$native_name = $q_config['language_name'][$lang];
}
return $q_config['language-names'][$lang] = $native_name;
}
$n = $translations->entries[$locale]->translations[0];
if (empty($q_config['language_name_case'])) {
//Camel Case by default
if (function_exists('mb_convert_case')) {
// module 'mbstring' may not be installed by default: https://wordpress.org/support/topic/qtranslate_utilsphp-on-line-504
$n = mb_convert_case($n, MB_CASE_TITLE);
} else {
$msg = 'qTranslate-X: Enable PHP module "mbstring" to get names of languages printed in "Camel Case" or disable option \'Show language names in "Camel Case"\' on admin page ' . admin_url('options-general.php?page=qtranslate-x#general') . '. You may find more information at http://php.net/manual/en/mbstring.installation.php, or search for PHP installation options on control panel of your server provider.';
error_log($msg);
}
}
return $q_config['language-names'][$lang] = $n;
}
开发者ID:vinnygats,项目名称:qtranslate-x,代码行数:51,代码来源:qtranslate_utils.php
注:本文中的get_translations_for_domain函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论