Changeset 6916 for trunk/wp-includes/l10n.php
- Timestamp:
- 02/19/2008 08:28:54 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/l10n.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/l10n.php
r6726 r6916 65 65 * @return string Translated text 66 66 */ 67 function translate($text, $domain ) {67 function translate($text, $domain = 'default') { 68 68 global $l10n; 69 69 … … 75 75 76 76 /** 77 * __() - Retrieve a translated string 78 * 79 * __() is a convenience function which retrieves the translated 80 * string from the translate(). 81 * 82 * @see translate() An alias of translate() 83 * @since 2.1.0 84 * 85 * @param string $text Text to translate 86 * @param string $domain Optional. Domain to retrieve the translated text 77 * translate_with_context() - Retrieve the translated text and strip context 78 * 79 * If the domain is set in the $l10n global, then the text is run 80 * through the domain's translate method. After it is passed to 81 * the 'gettext' filter hook, along with the untranslated text as 82 * the second parameter. 83 * 84 * If the domain is not set, the $text is just returned. 85 * 86 * @since 2.5 87 * @uses translate() 88 * 89 * @param string $text Text to translate 90 * @param string $domain Domain to retrieve the translated text 87 91 * @return string Translated text 88 92 */ 89 function __($text, $domain = 'default') { 90 return translate($text, $domain); 91 } 92 93 // . 94 /** 95 * _e() - Display a translated string 96 * 97 * _e() is a convenience function which displays the returned 98 * translated text from translate(). 99 * 100 * @see translate() Echos returned translate() string 101 * @since 1.2.0 102 * 103 * @param string $text Text to translate 104 * @param string $domain Optional. Domain to retrieve the translated text 105 */ 106 function _e($text, $domain = 'default') { 107 echo translate($text, $domain); 108 } 109 110 /** 111 * _c() - Retrieve context translated string 112 * 113 * Quite a few times, there will be collisions with similar 114 * translatable text found in more than two places but with 115 * different translated context. 116 * 117 * In order to use the separate contexts, the _c() function 118 * is used and the translatable string uses a pipe ('|') 119 * which has the context the string is in. 120 * 121 * When the translated string is returned, it is everything 122 * before the pipe, not including the pipe character. If 123 * there is no pipe in the translated text then everything 124 * is returned. 125 * 126 * @since 2.2.0 127 * 128 * @param string $text Text to translate 129 * @param string $domain Optional. Domain to retrieve the translated text 130 * @return string Translated context string without pipe 131 */ 132 function _c($text, $domain = 'default') { 93 function translate_with_context($text, $domain = 'default') { 133 94 $whole = translate($text, $domain); 134 95 $last_bar = strrpos($whole, '|'); … … 138 99 return substr($whole, 0, $last_bar); 139 100 } 101 } 102 103 /** 104 * __() - Retrieve a translated string 105 * 106 * __() is a convenience function which retrieves the translated 107 * string from the translate(). 108 * 109 * @see translate() An alias of translate() 110 * @since 2.1.0 111 * 112 * @param string $text Text to translate 113 * @param string $domain Optional. Domain to retrieve the translated text 114 * @return string Translated text 115 */ 116 function __($text, $domain = 'default') { 117 return translate($text, $domain); 118 } 119 120 // . 121 /** 122 * _e() - Display a translated string 123 * 124 * _e() is a convenience function which displays the returned 125 * translated text from translate(). 126 * 127 * @see translate() Echos returned translate() string 128 * @since 1.2.0 129 * 130 * @param string $text Text to translate 131 * @param string $domain Optional. Domain to retrieve the translated text 132 */ 133 function _e($text, $domain = 'default') { 134 echo translate($text, $domain); 135 } 136 137 /** 138 * _c() - Retrieve context translated string 139 * 140 * Quite a few times, there will be collisions with similar 141 * translatable text found in more than two places but with 142 * different translated context. 143 * 144 * In order to use the separate contexts, the _c() function 145 * is used and the translatable string uses a pipe ('|') 146 * which has the context the string is in. 147 * 148 * When the translated string is returned, it is everything 149 * before the pipe, not including the pipe character. If 150 * there is no pipe in the translated text then everything 151 * is returned. 152 * 153 * @since 2.2.0 154 * 155 * @param string $text Text to translate 156 * @param string $domain Optional. Domain to retrieve the translated text 157 * @return string Translated context string without pipe 158 */ 159 function _c($text, $domain = 'default') { 160 return translate_with_context($text, $domain); 140 161 } 141 162
Note: See TracChangeset
for help on using the changeset viewer.