コード例 #1
0
ファイル: i18n.php プロジェクト: davnopora/first
/**
 * Filters 'ngettext_with_context' to change the translations used for each of the extensions' textdomains.
 *
 * @since  0.9.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 omega_extensions_ngettext_with_context($translated, $single, $plural, $number, $context, $domain)
{
    $extensions = array('custom-field-series', 'featured-header', 'post-stylesheets');
    /* 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 (omega_is_textdomain_loaded('omega')) {
            $translated = omega_translate_plural('omega', $single, $plural, $number, $context);
        } elseif (omega_is_textdomain_loaded(omega_get_parent_textdomain())) {
            $translated = omega_translate_plural(omega_get_parent_textdomain(), $single, $plural, $number, $context);
        }
    }
    return $translated;
}
コード例 #2
0
ファイル: framework.php プロジェクト: ninthlink/edtech
 /**
  * Loads both the parent and child theme translation files.  If a locale-based functions file exists
  * in either the parent or child theme (child overrides parent), it will also be loaded.  All translation 
  * and locale functions files are expected to be within the theme's '/languages' folder, but the 
  * framework will fall back on the theme root folder if necessary.  Translation files are expected 
  * to be prefixed with the template or stylesheet path (example: 'templatename-en_US.mo').
  *
  * @since  0.9.0
  * @access public
  * @return void
  */
 function i18n()
 {
     global $omega;
     /* Get parent and child theme textdomains. */
     $parent_textdomain = omega_get_parent_textdomain();
     $child_textdomain = omega_get_child_textdomain();
     /* Load the framework textdomain. */
     $omega->textdomain_loaded['omega'] = omega_load_framework_textdomain('omega');
     /* Load theme textdomain. */
     $omega->textdomain_loaded[$parent_textdomain] = load_theme_textdomain($parent_textdomain);
     /* Load child theme textdomain. */
     $omega->textdomain_loaded[$child_textdomain] = is_child_theme() ? load_child_theme_textdomain($child_textdomain) : false;
     /* Get the user's locale. */
     $locale = get_locale();
     /* Locate a locale-specific functions file. */
     $locale_functions = locate_template(array("languages/{$locale}.php", "{$locale}.php"));
     /* If the locale file exists and is readable, load it. */
     if (!empty($locale_functions) && is_readable($locale_functions)) {
         require_once $locale_functions;
     }
 }