Make WordPress Core

Ticket #26638: 26638.2.patch

File 26638.2.patch, 2.5 KB (added by SergeyBiryukov, 11 years ago)
  • wp-includes/l10n.php

     
    7171 * @return string Translated text
    7272 */
    7373function translate( $text, $domain = 'default' ) {
    74         $translations = get_translations_for_domain( $domain );
    75         $translations = $translations->translate( $text );
     74        global $l10n;
     75
     76        if ( isset( $l10n[ $domain ] ) ) {
     77                $translations = get_translations_for_domain( $domain );
     78                $translations = $translations->translate( $text );
     79        } else {
     80                $translations = $text;
     81        }
     82
    7683        /**
    7784         * Filter text with its translation.
    7885         *
     
    118125 * @return string Translated text on success, original text on failure.
    119126 */
    120127function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
    121         $translations = get_translations_for_domain( $domain );
    122         $translations = $translations->translate( $text, $context );
     128        global $l10n;
     129
     130        if ( isset( $l10n[ $domain ] ) ) {
     131                $translations = get_translations_for_domain( $domain );
     132                $translations = $translations->translate( $text, $context );
     133        } else {
     134                $translations = $text;
     135        }
     136
    123137        /**
    124138         * Filter text with its translation based on context information.
    125139         *
     
    295309 * @return string Either $single or $plural translated text.
    296310 */
    297311function _n( $single, $plural, $number, $domain = 'default' ) {
    298         $translations = get_translations_for_domain( $domain );
    299         $translation = $translations->translate_plural( $single, $plural, $number );
     312        global $l10n;
     313
     314        if ( isset( $l10n[ $domain ] ) ) {
     315                $translations = get_translations_for_domain( $domain );
     316                $translation = $translations->translate_plural( $single, $plural, $number );
     317        } else {
     318                $translation = ( 1 == $number ) ? $single : $plural;
     319        }
     320
    300321        /**
    301322         * Filter text with its translation when plural option is available.
    302323         *
     
    326347 * @return string Either $single or $plural translated text with context.
    327348 */
    328349function _nx($single, $plural, $number, $context, $domain = 'default') {
    329         $translations = get_translations_for_domain( $domain );
    330         $translation = $translations->translate_plural( $single, $plural, $number, $context );
     350        global $l10n;
     351
     352        if ( isset( $l10n[ $domain ] ) ) {
     353                $translations = get_translations_for_domain( $domain );
     354                $translation = $translations->translate_plural( $single, $plural, $number, $context );
     355        } else {
     356                $translation = ( 1 == $number ) ? $single : $plural;
     357        }
     358
    331359        /**
    332360         * Filter text with its translation while plural option and context are available.
    333361         *