X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/7688c6ba71852cd89123b62b2d57683535e4702a..959f97d8ecd5c1668103a3e41c795486b944bc68:/wp-includes/l10n.php?ds=sidebyside diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 4dba6798..0584f9da 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -1,4 +1,32 @@ ngettext_noop('%s post', '%s posts'), + * 'page' => ngettext_noop('%s pages', '%s pages') + * ); + * ... + * $message = $messages[$type]; + * $usable_text = sprintf(__ngettext($message[0], $message[1], $count), $count); + * + * @since 2.5 + * @param $single Single form to be i18ned + * @param $plural Plural form to be i18ned + * @param $number Not used, here for compatibility with __ngettext, optional + * @param $domain Not used, here for compatibility with __ngettext, optional + * @return array array($single, $plural) + */ +function __ngettext_noop($single, $plural, $number=1, $domain = 'default') { + return array($single, $plural); +} + +/** + * load_textdomain() - Loads MO file into the list of domains + * + * If the domain already exists, the inclusion will fail. If the + * MO file is not readable, the inclusion will fail. + * + * On success, the mofile will be placed in the $l10n global by + * $domain and will be an gettext_reader 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 + * + * @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. + */ function load_textdomain($domain, $mofile) { global $l10n; @@ -74,9 +253,15 @@ function load_textdomain($domain, $mofile) { $l10n[$domain] = new gettext_reader($input); } +/** + * load_default_textdomain() - Loads default translated strings based on locale + * + * Loads the .mo file in LANGDIR constant path from WordPress root. + * The translated (.mo) file is named based off of the locale. + * + * @since 1.5.0 + */ function load_default_textdomain() { - global $l10n; - $locale = get_locale(); if ( empty($locale) ) $locale = 'en_US'; @@ -86,6 +271,24 @@ function load_default_textdomain() { load_textdomain('default', $mofile); } +/** + * load_plugin_textdomain() - Loads the plugin's translated strings + * + * If the path is not given then it will be the root of the plugin + * directory. The .mo file should be named based on the domain with a + * dash followed by a dash, and then the locale exactly. + * + * The plugin may place all of the .mo files in another folder and set + * the $path based on the relative location from ABSPATH constant. The + * plugin may use the constant PLUGINDIR and/or plugin_basename() to + * get path of the plugin and then add the folder which holds the .mo + * files. + * + * @since 1.5.0 + * + * @param string $domain Unique identifier for retrieving translated strings + * @param string $path Optional. Path of the folder where the .mo files reside. + */ function load_plugin_textdomain($domain, $path = false) { $locale = get_locale(); if ( empty($locale) ) @@ -98,6 +301,18 @@ function load_plugin_textdomain($domain, $path = false) { load_textdomain($domain, $mofile); } +/** + * load_theme_textdomain() - Includes theme's translated strings for the theme + * + * If the current locale exists as a .mo file in the theme's root directory, it + * will be included in the translated strings by the $domain. + * + * The .mo files must be named based on the locale exactly. + * + * @since 1.5.0 + * + * @param string $domain Unique identifier for retrieving translated strings + */ function load_theme_textdomain($domain) { $locale = get_locale(); if ( empty($locale) )