/** * Loads the theme, child theme, and framework textdomains automatically. No need for theme authors * to do this. This also utilizes the `Domain Path` header from `style.css`. It defaults to the * `languages` folder. Theme authors should define this as `/lang`, `/languages` or some other * variation of their choosing. * * @since 3.0.0 * @access public * @return void */ function hybrid_load_textdomains() { // Load theme textdomain. load_theme_textdomain(hybrid_get_parent_textdomain(), HYBRID_PARENT . hybrid_get_parent_domain_path()); // Load child theme textdomain. if (is_child_theme()) { load_child_theme_textdomain(hybrid_get_child_textdomain(), HYBRID_CHILD . hybrid_get_child_domain_path()); } // Load the framework textdomain. hybrid_load_framework_textdomain(); }
/** * 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.2.0 */ function i18n() { global $hybrid; /* Get parent and child theme textdomains. */ $parent_textdomain = hybrid_get_parent_textdomain(); $child_textdomain = hybrid_get_child_textdomain(); /* Load the framework textdomain. */ $hybrid->textdomain_loaded['hybrid-core'] = hybrid_load_framework_textdomain('hybrid-core'); /* Load theme textdomain. */ $hybrid->textdomain_loaded[$parent_textdomain] = load_theme_textdomain($parent_textdomain); /* Load child theme textdomain. */ $hybrid->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; } }
/** * 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.2.0 * @access public * @return void */ function i18n() { global $hybrid; /* Get parent and child theme textdomains. */ $parent_textdomain = hybrid_get_parent_textdomain(); $child_textdomain = hybrid_get_child_textdomain(); /* Load theme textdomain. */ $hybrid->textdomain_loaded[$parent_textdomain] = load_theme_textdomain($parent_textdomain); /* Load child theme textdomain. */ $hybrid->textdomain_loaded[$child_textdomain] = is_child_theme() ? load_child_theme_textdomain($child_textdomain) : false; /* Load the framework textdomain. */ $hybrid->textdomain_loaded['hybrid-core'] = hybrid_load_framework_textdomain('hybrid-core'); /* Load empty textdomain mofiles for extensions (these will be overwritten). */ if (current_theme_supports('breadcrumb-trail')) { load_textdomain('breadcrumb-trail', ''); } if (current_theme_supports('post-stylesheets')) { load_textdomain('post-stylesheets', ''); } if (current_theme_supports('theme-layouts')) { load_textdomain('theme-layouts', ''); } /* 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; } }
/** * 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.2.0 */ function i18n() { /* Load the framework textdomain. */ hybrid_load_framework_textdomain('hybrid-core'); /* Load theme textdomain. */ load_theme_textdomain(hybrid_get_parent_textdomain()); /* Load child theme textdomain. */ if (is_child_theme()) { load_child_theme_textdomain(hybrid_get_child_textdomain()); } /* 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; } }