示例#1
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.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 bon_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 (bon_is_textdomain_loaded('bon')) {
                $translations =& get_translations_for_domain('bon');
            } elseif (bon_is_textdomain_loaded(bon_get_parent_textdomain())) {
                $translations =& get_translations_for_domain(bon_get_parent_textdomain());
            }
            /* If translations were found, translate the text. */
            if (!empty($translations)) {
                $translated = $translations->translate($text);
            }
        }
    }
    return $translated;
}
示例#2
0
 /**
  * handle theme textdomain and language.
  *
  * @access public
  * @return void
  */
 public function i18n()
 {
     /* Get parent and child theme textdomains. */
     $parent_textdomain = bon_get_parent_textdomain();
     $child_textdomain = bon_get_child_textdomain();
     /* Load the framework textdomain. */
     $bon->textdomain_loaded['bon'] = bon_load_framework_textdomain('bon');
     /* Load theme textdomain. */
     $bon->textdomain_loaded[$parent_textdomain] = load_theme_textdomain($parent_textdomain);
     /* Load child theme textdomain. */
     $bon->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;
     }
 }