3 if ( defined('WPLANG') && '' != constant('WPLANG') ) {
4 include_once(ABSPATH . 'wp-includes/streams.php');
5 include_once(ABSPATH . 'wp-includes/gettext.php');
8 function get_locale() {
14 // WPLANG is defined in wp-config.
15 if (defined('WPLANG'))
21 $locale = apply_filters('locale', $locale);
26 // Return a translated string.
27 function __($text, $domain = 'default') {
30 if (isset($l10n[$domain]))
31 return apply_filters('gettext', $l10n[$domain]->translate($text), $text);
36 // Echo a translated string.
37 function _e($text, $domain = 'default') {
40 if (isset($l10n[$domain]))
41 echo apply_filters('gettext', $l10n[$domain]->translate($text), $text);
46 // Return the plural form.
47 function __ngettext($single, $plural, $number, $domain = 'default') {
50 if (isset($l10n[$domain])) {
51 return $l10n[$domain]->ngettext($single, $plural, $number);
60 function load_textdomain($domain, $mofile) {
63 if (isset($l10n[$domain]))
66 if ( is_readable($mofile))
67 $input = new CachedFileReader($mofile);
71 $l10n[$domain] = new gettext_reader($input);
74 function load_default_textdomain() {
77 $locale = get_locale();
78 $mofile = ABSPATH . "wp-includes/languages/$locale.mo";
80 load_textdomain('default', $mofile);
83 function load_plugin_textdomain($domain, $path = 'wp-content/plugins') {
84 $locale = get_locale();
86 $mofile = ABSPATH . "$path/$domain-$locale.mo";
87 load_textdomain($domain, $mofile);
90 function load_theme_textdomain($domain) {
91 $locale = get_locale();
93 $mofile = get_template_directory() . "/$locale.mo";
94 load_textdomain($domain, $mofile);