From 3090ebd2b5277b5d5848faee4f325b0f065dcbbd Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 1 Jul 2009 20:05:14 +0000 Subject: [PATCH] Update load_textdomain() phpdoc. Props nbachiyski. fixes #10286 for trunk git-svn-id: https://develop.svn.wordpress.org/trunk@11680 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/l10n.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 23ab4ebaf0..0485049727 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -301,35 +301,34 @@ function _nx_noop( $single, $plural, $context ) { /** - * Loads MO file into the list of domains. + * Loads a MO file into the domain $domain. * - * If the domain already exists, the inclusion will fail. If the MO file is not - * readable, the inclusion will fail. + * If the domain already exists, the translations will be merged. If both + * sets have the same string, the translation from the original value will be taken. * * On success, the .mo file will be placed in the $l10n global by $domain - * and will be an gettext_reader object. + * and will be a MO object. * * @since 1.5.0 - * @uses $l10n Gets list of domain translated string (gettext_reader) objects - * @uses CacheFileReader Reads the MO file - * @uses gettext_reader Allows for retrieving translated strings + * @uses $l10n Gets list of domain translated string objects * * @param string $domain Unique identifier for retrieving translated strings * @param string $mofile Path to the .mo file - * @return null On failure returns null and also on success returns nothing. + * @return bool true on success, false on failure */ function load_textdomain($domain, $mofile) { global $l10n; - if ( !is_readable($mofile)) return; + if ( !is_readable( $mofile ) ) return false; $mo = new MO(); - $mo->import_from_file( $mofile ); + if ( !$mo->import_from_file( $mofile ) ) return false; - if (isset($l10n[$domain])) + if ( isset( $l10n[$domain] ) ) $mo->merge_with( $l10n[$domain] ); $l10n[$domain] = &$mo; + return true; } /** @@ -345,7 +344,7 @@ function load_default_textdomain() { $mofile = WP_LANG_DIR . "/$locale.mo"; - load_textdomain('default', $mofile); + return load_textdomain('default', $mofile); } /** @@ -372,7 +371,7 @@ function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path $path = WP_PLUGIN_DIR; $mofile = $path . '/'. $domain . '-' . $locale . '.mo'; - load_textdomain($domain, $mofile); + return load_textdomain($domain, $mofile); } /** @@ -393,7 +392,7 @@ function load_theme_textdomain($domain, $path = false) { $path = ( empty( $path ) ) ? get_template_directory() : $path; $mofile = "$path/$locale.mo"; - load_textdomain($domain, $mofile); + return load_textdomain($domain, $mofile); } /**