public static function _x($text, $context, $domain = null) { if (!$domain) { $domain = Core::ID; } return \translate_with_gettext_context($text, $context, $domain); }
/** * Translates role name. Since the role names are in the database and * not in the source there are dummy gettext calls to get them into the POT * file and this function properly translates them back. * * The before_last_bar() call is needed, because older installs keep the roles * using the old context format: 'Role name|User role' and just skipping the * content after the last bar is easier than fixing them in the DB. New installs * won't suffer from that problem. */ function translate_user_role($name) { return translate_with_gettext_context(before_last_bar($name), 'User role'); }
<?php /** * A set of WordPress translation functions. * * @see wp-includes/l10n.php */ translate('translate'); translate_with_gettext_context('translate_with_gettext_context', 'translate_with_gettext_context-context'); __('__'); esc_attr__('esc_attr__'); esc_html__('esc_html__'); _e('_e'); esc_attr_e('esc_attr_e'); esc_html_e('esc_html_e'); _x('_x', '_x-context'); _ex('_ex', '_ex-context'); esc_attr_x('esc_attr_x', 'esc_attr_x-context'); esc_html_x('esc_html_x', 'esc_html_x-context'); _n('_n-single', '_n-plural', 2); _nx('_nx-single', '_nx-plural', 2, '_nx-context'); _n_noop('_n_noop-singular', '_n_noop-plural'); _nx_noop('_nx_noop-singular', '_nx_noop-plural', '_nx_noop-context');
/** * __x * * @param string $text Text to translate. * @param string $context Context information for the translators. * @param string $domain Optional. Text domain. Unique identifier for retrieving translated * @return string Translated context string without pipe. * @version 1.0.1 */ function __x($text, $context, $domain = null) { if (!$domain) { $domain = theme_functions::$iden; } return translate_with_gettext_context($text, $context, $domain); }
/** * Shopp wrapper for gettext translation strings (with optional context and Markdown support) * * @author Jonathan Davis * @since 1.3 * * @param string $text The text to translate * @param string $context An explination of how and where the text is used * @return string The translated text **/ public static function translate($text, $context = null) { $domain = 'Shopp'; if (is_null($context)) { $string = translate($text, $domain); } else { $string = translate_with_gettext_context($text, $context, $domain); } return $string; }
function _x($single, $context, $domain = 'default') { return translate_with_gettext_context($single, $context, $domain); }
function wpdev_141551_translate_user_roles($translations, $text, $context, $domain) { $plugin_domain = 'learn_press'; $roles = array('Instructor'); if ($context === 'User role' && in_array($text, $roles) && $domain !== $plugin_domain) { return translate_with_gettext_context($text, $context, $plugin_domain); } return $translations; }
public function ping_settings_field() { $options = parent::get_ping(); $defaults = parent::defaults('ping'); $update_services = get_option('ping_sites'); $prefix = parent::prefix(); $names = array('google' => array('name' => __('Google', 'xml-sitemap-feed')), 'bing' => array('name' => __('Bing & Yahoo', 'xml-sitemap-feed')), 'yandex' => array('name' => __('Yandex', 'xml-sitemap-feed')), 'baidu' => array('name' => __('Baidu', 'xml-sitemap-feed')), 'others' => array('name' => __('Ping-O-Matic', 'xml-sitemap-feed'))); foreach ($names as $key => $values) { if (array_key_exists($key, $defaults) && is_array($values)) { $defaults[$key] += $values; } } echo ' <fieldset id="xmlsf_ping"><legend class="screen-reader-text">' . translate('Update Services') . '</legend> '; foreach ($defaults as $key => $values) { if (isset($values['type']) && $values['type'] == 'RPC') { $active = strpos($update_services, untrailingslashit($values['uri'])) === false ? false : true; } else { $active = !empty($options[$key]['active']) ? true : false; } echo ' <label><input type="checkbox" name="' . $prefix . 'ping[' . $key . '][active]" id="xmlsf_ping_' . $key . '" value="1"' . checked($active, true, false) . ' /> '; echo isset($names[$key]) && !empty($names[$key]['name']) ? $names[$key]['name'] : $key; echo '</label>'; echo ' <input type="hidden" name="' . $prefix . 'ping[' . $key . '][uri]" value="' . $values['uri'] . '" />'; echo ' <input type="hidden" name="' . $prefix . 'ping[' . $key . '][type]" value="' . $values['type'] . '" />'; if (isset($values['news'])) { echo ' <input type="hidden" name="' . $prefix . 'ping[' . $key . '][news]" value="' . $values['news'] . '" />'; } echo ' <span class="description">'; if (!empty($options[$key]['pong'])) { if ($tzstring = get_option('timezone_string')) { // use same timezoneformat as translatable examples in options-general.php $timezone_format = translate_with_gettext_context('Y-m-d G:i:s', 'timezone date format'); date_default_timezone_set($tzstring); } else { $timezone_format = 'Y-m-d G:i:s T'; } foreach ((array) $options[$key]['pong'] as $pretty => $time) { echo ' <input type="hidden" name="' . $prefix . 'ping[' . $key . '][pong][' . $pretty . ']" value="' . $time . '" />'; if (!empty($time)) { echo sprintf(__('Successfully sent %1$s on %2$s.', 'xml-sitemap-feed'), $pretty, date($timezone_format, $time)) . ' '; } } date_default_timezone_set('UTC'); } echo '</span><br>'; } echo ' </fieldset>'; }
function esc_attr_x($single, $context, $domain = 'default') { return esc_attr(translate_with_gettext_context($single, $context, $domain)); }
/** * Shortcut for the esc_html_x function * @param string $text * @param string $domain */ function esc_html_x_emp($text, $context, $domain = 'dbem') { return esc_html(translate_with_gettext_context($text, $context, $domain)); }
/** * Shortcode inside post content * [linked-post-in lang="fr_fr"]Voir cet article[/linked-post-in] * */ function build_linked_posts_shortcode($atts, $content = null) { global $post; extract(shortcode_atts(array('lang' => '', 'title' => '', 'context' => 'linktitle'), $atts)); $language = xiliml_get_language($lang); /* test if lang is available */ if ($language !== false) { $otherpost = $this->linked_post_in($post->ID, $language->slug); } if ($otherpost) { if ('' == $title) { $obj_lang = xiliml_get_lang_object_of_post($otherpost); if (false !== $obj_lang) { $description = $obj_lang->description; if ($context) { $text_title = translate_with_gettext_context('A similar post in %s', $context, $this->thetextdomain); $language_name = translate_with_gettext_context($description, $context, $this->thetextdomain); } else { $text_title = translate('A similar post in %s', $this->thetextdomain); $language_name = translate($description, $this->thetextdomain); } $title = esc_html(sprintf($text_title, $language_name)); } else { $title = esc_html(__('Error with target post #', 'xili-language')) . $otherpost; } } $output = '<a href="' . get_permalink($otherpost) . '" title="' . $title . '">' . $content . '</a>'; /* this link above can be enriched by image or flag inside $content */ } else { $output = '<a href="#" title="' . __('Error: other post not present !!!', 'xili-language') . '">' . $content . '</a>'; } return $output; }