WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/01/2018 01:50:59 PM (20 months ago)
Author:
herregroen
Message:

I18N: Improve JavaScript translation support.

Improves upon [43825] by adding unit tests to cover additional use-cases and changes loading translations to only occur when outputting the script to allow setting translations on dependencies.

Props atimmer, omarreiss, nerrad, swissspidy, ocean90.
Fixes #45103.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/class-wp-dependency.php

    r41162 r43859  
    6969
    7070    /**
     71     * Translation textdomain set for this dependency.
     72     *
     73     * @since 5.0.0
     74     * @var string
     75     */
     76    public $textdomain;
     77
     78    /**
     79     * Translation path set for this dependency.
     80     *
     81     * @since 5.0.0
     82     * @var string
     83     */
     84    public $translations_path;
     85
     86    /**
    7187     * Setup dependencies.
    7288     *
     
    95111    }
    96112
     113    public function set_translations( $domain, $path = null ) {
     114        if ( !is_string($domain) )
     115            return false;
     116        $this->textdomain        = $domain;
     117        $this->translations_path = $path;
     118        return true;
     119    }
    97120}
Note: See TracChangeset for help on using the changeset viewer.