예제 #1
0
파일: hoot.php 프로젝트: ergray/desertrose
 /**
  * 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 1.0.0
  * @access public
  * @return void
  */
 function i18n()
 {
     global $hoot;
     /* Get parent and child theme textdomains. */
     $parent_textdomain = hoot_get_parent_textdomain();
     $child_textdomain = hoot_get_child_textdomain();
     /* Load theme textdomain. */
     $hoot->textdomain_loaded[$parent_textdomain] = load_theme_textdomain($parent_textdomain, get_template_directory() . '/languages');
     /* Load child theme textdomain. */
     $hoot->textdomain_loaded[$child_textdomain] = is_child_theme() ? load_child_theme_textdomain($child_textdomain) : false;
     /* Load the framework textdomain. */
     // @disabled: WordPress standards allow only 1 text domain (theme slug), so we will stick to that.
     // $hoot->textdomain_loaded['hoot'] = hoot_load_framework_textdomain( 'hoot' );
     // $hoot->textdomain_loaded['hoot'] = hoot_load_framework_textdomain( 'hoot' );
     /* 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;
     }
 }
예제 #2
0
/**
 * Filters the 'load_textdomain_mofile' filter hook so that we can change the directory and file name 
 * of the mofile for translations.  This allows child themes to have a folder called /languages with translations
 * of their parent theme so that the translations aren't lost on a parent theme upgrade.
 *
 * @since 1.0.0
 * @access public
 * @param string $mofile File name of the .mo file.
 * @param string $domain The textdomain currently being filtered.
 * @return string
 */
function hoot_load_textdomain_mofile($mofile, $domain)
{
    /* If the $domain is for the parent or child theme, search for a $domain-$locale.mo file. */
    if ($domain == hoot_get_parent_textdomain() || $domain == hoot_get_child_textdomain()) {
        /* Check for a $domain-$locale.mo file in the parent and child theme root and /languages folder. */
        $locale = get_locale();
        $locate_mofile = locate_template(array("languages/{$domain}-{$locale}.mo", "{$domain}-{$locale}.mo"));
        /* If a mofile was found based on the given format, set $mofile to that file name. */
        if (!empty($locate_mofile)) {
            $mofile = $locate_mofile;
        }
    }
    /* Return the $mofile string. */
    return $mofile;
}