Make WordPress Core


Ignore:
Timestamp:
12/14/2018 05:51:31 AM (8 years ago)
Author:
pento
Message:

I18N: Add JavaScript translation support.

Adds the wp_set_script_translations() function which registers translations for a JavaScript file. This function takes a handle, domain and optionally a path and ensures JavaScript translation files are loaded if they exist.

Merges [43825,43828,43859,43898] from the 5.0 branch to trunk.

Props herregroen, atimmer, omarreiss, nerrad, swissspidy, ocean90, georgestephanis.
Fixes #45103, #45256.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/class-wp-dependency.php

    r42343 r44169  
    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         *
    … …  
    97113        }
    98114
     115        public function set_translations( $domain, $path = null ) {
     116                if ( ! is_string( $domain ) ) {
     117                        return false;
     118                }
     119                $this->textdomain        = $domain;
     120                $this->translations_path = $path;
     121                return true;
     122        }
    99123}
Note: See TracChangeset for help on using the changeset viewer.