Example #1
0
File: i18n.php Project: RA2WP/RA2WP
/**
 * Filters 'ngettext_with_context' to change the translations used for each of the extensions' textdomains.
 *
 * @since  1.6.0
 * @access public
 * @param  string $translated The translated text.
 * @param  string $single     The singular form of the untranslated text.
 * @param  string $plural     The plural form of the untranslated text.
 * @param  int    $number     The number to use to base whether something is singular or plural.
 * @param  string $context    The context of the text.
 * @param  string $domain     The textdomain for the text.
 * @return string
 */
function hybrid_extensions_ngettext_with_context($translated, $single, $plural, $number, $context, $domain)
{
    $extensions = array('breadcrumb-trail', 'custom-field-series', 'featured-header', 'post-stylesheets', 'theme-fonts', 'theme-layouts');
    /* Check if the current textdomain matches one of the framework extensions. */
    if (in_array($domain, $extensions) && current_theme_supports($domain)) {
        /* If the framework mofile is loaded, use its translations. */
        if (hybrid_is_textdomain_loaded('hybrid-core')) {
            $translated = hybrid_translate_plural('hybrid-core', $single, $plural, $number, $context);
        } elseif (hybrid_is_textdomain_loaded(hybrid_get_parent_textdomain())) {
            $translated = hybrid_translate_plural(hybrid_get_parent_textdomain(), $single, $plural, $number, $context);
        }
    }
    return $translated;
}
Example #2
0
/**
 * 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;
}