Commit Graph

197 Commits

Author SHA1 Message Date
John Blackbourn
f545bb3f63 Docs: Improve documentation of known return types, plus other docs fixes.
See #48303

Built from https://develop.svn.wordpress.org/trunk@46660


git-svn-id: http://core.svn.wordpress.org/trunk@46460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-05 21:23:02 +00:00
John Blackbourn
c8f91f77ac Docs: Correct invalid hook docblocks.
See #48303

Built from https://develop.svn.wordpress.org/trunk@46603


git-svn-id: http://core.svn.wordpress.org/trunk@46400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-27 19:11:02 +00:00
Sergey Biryukov
552852d887 Docs: Improve documentation for esc_attr_e(), esc_html_e(), esc_attr_x(), esc_html_x().
Props atachibana.
Fixes #48383.
Built from https://develop.svn.wordpress.org/trunk@46593


git-svn-id: http://core.svn.wordpress.org/trunk@46390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-26 17:30:03 +00:00
John Blackbourn
e36d1bcbd8 Docs: Docblock corrections and improvements, mostly related to various pre_* filters.
See #47110

Built from https://develop.svn.wordpress.org/trunk@46232


git-svn-id: http://core.svn.wordpress.org/trunk@46044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-21 17:41:57 +00:00
Sergey Biryukov
77a31e6875 Docs: Add missing description for $wp_locale_switcher global.
See #45604, #47110.
Built from https://develop.svn.wordpress.org/trunk@45738


git-svn-id: http://core.svn.wordpress.org/trunk@45549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:47:55 +00:00
Sergey Biryukov
e0311b76c7 Docs: Add missing description for $wp_locale global.
Props mukesh27.
See #45604, #47110.
Built from https://develop.svn.wordpress.org/trunk@45737


git-svn-id: http://core.svn.wordpress.org/trunk@45548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:46:55 +00:00
Dominik Schilling
8059b362e8 I18N: Add support for custom WP_PLUGIN_URL in load_script_textdomain().
Plugins may not be on the same host/path as the rest of the content. To support loading translations for this setup check if the script source matches `plugins_url()`.
Also fixes an undefined index notice when a custom content URL has no path.

Props odminstudios, ocean90.
Fixes #46336, #46387.
Built from https://develop.svn.wordpress.org/trunk@45685


git-svn-id: http://core.svn.wordpress.org/trunk@45496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-27 12:44:56 +00:00
Gary Pendergast
4803fc405e Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in wp-includes.
See #47632.


Built from https://develop.svn.wordpress.org/trunk@45590


git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-02 23:42:58 +00:00
Sergey Biryukov
355d5f9bb7 Docs: Correct @param type for $deprecated and $plugin_rel_path arguments of load_plugin_textdomain().
Props sudar.
Fixes #43304.
Built from https://develop.svn.wordpress.org/trunk@45254


git-svn-id: http://core.svn.wordpress.org/trunk@45063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-19 14:21:53 +00:00
Dominik Schilling
24e2829eb9 I18N: Add $domain argument to translate_user_role().
The text domain is optional and gets passed to `translate_with_gettext_context()`.

Props johnjamesjacoby	.
Fixes #38736.
Built from https://develop.svn.wordpress.org/trunk@44830


git-svn-id: http://core.svn.wordpress.org/trunk@44662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-11 20:32:52 +00:00
Pascal Birchler
a595f8a525 I18N: Add option to hide en_US locale in wp_dropdown_languages().
Props danieltj for initial patch.
Fixes #44494.

Built from https://develop.svn.wordpress.org/trunk@44514


git-svn-id: http://core.svn.wordpress.org/trunk@44345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-09 11:46:50 +00:00
Dominik Schilling
86e5a051db I18n: Expose JSON translation file paths in load_script_textdomain().
Removes `file_exist()` checks before calling `load_script_translations()` to let the determined paths be passed to `load_script_translations()` which provides its own file check and the possibility to filter the path.

Props swissspidy, johnbillion, ocean90.
See #45769.
Built from https://develop.svn.wordpress.org/trunk@44418


git-svn-id: http://core.svn.wordpress.org/trunk@44248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-07 13:59:51 +00:00
Dominik Schilling
f34e1dbad1 I18N: Make domain argument optional in wp_set_script_translations() / WP_Scripts::set_translations().
Props swissspidy.
Fixes #45489.
Built from https://develop.svn.wordpress.org/trunk@44395


git-svn-id: http://core.svn.wordpress.org/trunk@44225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-04 21:12:50 +00:00
Sergey Biryukov
11c11199d9 i18n: Remove the script_loader_src filter from load_script_textdomain().
This filter is superfluous here, the `load_script_textdomain_relative_path` should be used for customising the textdomain path.

Props dimadin.
Merges [44288] to trunk.
See #45528.
Built from https://develop.svn.wordpress.org/trunk@44318


git-svn-id: http://core.svn.wordpress.org/trunk@44148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-19 03:34:44 +00:00
Sergey Biryukov
c2c5d30410 i18n: Prevent a PHP warning when a mu-plugin loads a textdomain.
`determine_locale()` accesses the `$pagenow` global, but this is set after mu-plugins are loaded, so we need to check that it's been set.

Props swissspidy, azaozz.
Merges [44284] to trunk.
Fixes #45668.
Built from https://develop.svn.wordpress.org/trunk@44317


git-svn-id: http://core.svn.wordpress.org/trunk@44147 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-19 03:33:56 +00:00
Sergey Biryukov
0094ea41a9 I18N: Introduce load_script_translations() as a wrapper for loading and filtering translation data for JavaScript files.
* Introduces `pre_load_script_translations` to short-circuit the function.
* Introduces `load_script_translation_file` to filter the file path for loading script translations.
* Introduces `load_script_translations` to filter the JSON-encoded translation data.

Props johnbillion, strategio, swissspidy, dimadin, ocean90.
Merges [44232] to trunk.
Fixes #45425.
Built from https://develop.svn.wordpress.org/trunk@44316


git-svn-id: http://core.svn.wordpress.org/trunk@44146 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-19 03:33:07 +00:00
desrosj
1605370d02 I18N: Fix JavaScript translations for subdirectory installations.
Fixes the `load_script_textdomain` function not resolving the md5 hash based on the relative path for WordPress installations in a subdirectory. Also adds a filter to allow sites using CDNs or other alternative asset locations to filter the relative path resolution.

Props akirk, fierevere, swissspidy, mypacecreator, babaevan, tmatsuur, ocean90, herregroen.

Merges [44209] to trunk.

Fixes #45528.
Built from https://develop.svn.wordpress.org/trunk@44310


git-svn-id: http://core.svn.wordpress.org/trunk@44140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-19 03:28:14 +00:00
desrosj
d92ccd83a0 l10n: Ensure JavaScript language packages are loaded for the user locale.
`load_script_textdomain()` had a reversed check to decide if the user locale should be loaded. This check is now replaced with `determine_local()`.

Props ocean90.

Merges [43959] into trunk.

Fixes #45465.
Built from https://develop.svn.wordpress.org/trunk@44278


git-svn-id: http://core.svn.wordpress.org/trunk@44108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 19:36:52 +00:00
atimmer
e055e026e3 l10n: Avoid calling is_user_logged_in() in determine_locale().
is_user_logged_in() is a pluggable function, and loaded after plugins are loaded. If a plugin calls __() too early, is_user_logged_in() is missing and WordPress will fatal. get_user_locale() already handles this scenario for us, so it's safe to rely on exclusively.

Props danielbachhuber.
Merges [43846] to trunk.
See #44758.
Fixes #45235.

Built from https://develop.svn.wordpress.org/trunk@44181


git-svn-id: http://core.svn.wordpress.org/trunk@44011 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 12:15:54 +00:00
Gary Pendergast
f46fbae857 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.


Built from https://develop.svn.wordpress.org/trunk@44169


git-svn-id: http://core.svn.wordpress.org/trunk@43999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 05:52:52 +00:00
Jeremy Felt
f93e24ca8e REST API: Render response in user locale with ?_locale=user.
Introduces new `determine_locale()` function for deciding the proper locale to use for a response. Default value is `get_user_locale()` in the admin, and `get_locale()` on the frontend. Because REST API requests are considered frontend requests, `?_locale=user` can be used to render the response in the user's locale.

Also updates `wp-login.php?wp_lang` implementation to benefit from this abstraction.

Merges [43776] from the 5.0 branch to trunk.

Props flixos90, mnelson4, swissspidy, TimothyBlynJacobs.
Fixes #44758.

Built from https://develop.svn.wordpress.org/trunk@44134


git-svn-id: http://core.svn.wordpress.org/trunk@43964 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 01:32:39 +00:00
Gary Pendergast
56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


Built from https://develop.svn.wordpress.org/trunk@43571


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
John Blackbourn
2361ca884f Docs: Document more parameters and properties using typed array notation.
See #41756

Built from https://develop.svn.wordpress.org/trunk@42876


git-svn-id: http://core.svn.wordpress.org/trunk@42706 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-25 19:33:31 +00:00
Dominik Schilling
5c291d49de Pinking shears.
See #41057.
Built from https://develop.svn.wordpress.org/trunk@42843


git-svn-id: http://core.svn.wordpress.org/trunk@42673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-18 14:23:33 +00:00
Pascal Birchler
5cde2018ea Docs: Remove erroneous period in the description for esc_html__().
Props danieltj.
Fixes #43419.

Built from https://develop.svn.wordpress.org/trunk@42753


git-svn-id: http://core.svn.wordpress.org/trunk@42583 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-26 15:57:32 +00:00
Drew Jaynes
6e665d1f15 Docs: Link to the "Conditional Tags" article in the Theme Developer Handbook from the descriptions for a variety of core conditional tag functions.
These notations largely serve to direct consumers (of both the source and the parsed code reference) to extended information on individual and related conditional tags throughout WordPress. The changeset also standardizes corresponding DocBlock summaries to use third-person singular verbs.

Notations been added for the following functions:

* comments_open()
* email exists()
* has_excerpt()
* has_post_thumbnail()
* has_tag()
* in_category()
* in_the_loop()
* is_404()
* is_active_sidebar()
* is_active_widget()
* is_admin()
* is_admin_bar_showing()
* is_archive()
* is_attachment()
* is_author()
* is_blog_installed()
* is_category()
* is_comments_popup()
* is_date()
* is_day()
* is_dynamic_sidebar()
* is_feed()
* is_front_page()
* is_home()
* is_local_attachment()
* is_main_query
* is_month()
* is_multi_author
* is_new_day()
* is_page()
* is_page_template()
* is_paged()
* is_plugin_active()
* is_plugin_active_for_network()
* is_plugin_inactive()
* is_plugin_page()
* is_post_type_archive()
* is_preview()
* is_rtl()
* is_search()
* is_single()
* is_singular()
* is_sticky()
* is_tag()
* is_tax()
* is_taxonomy_hierarchical()
* is_time()
* is_trackback()
* is_user_logged_in()
* is_year()
* pings_open()
* post_type_exists()
* taxonomy_exists()
* term_exists()
* username exists()
* wp_attachment_is_image()
* wp_script_is()

Props janalwin.
Fixes #43254.

Built from https://develop.svn.wordpress.org/trunk@42710


git-svn-id: http://core.svn.wordpress.org/trunk@42538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-13 16:54:31 +00:00
Sergey Biryukov
a3f69ffaa3 Docs: Add missing @staticvar entries in wp-includes/l10n.php.
Props birgire.
Fixes #42800.
Built from https://develop.svn.wordpress.org/trunk@42399


git-svn-id: http://core.svn.wordpress.org/trunk@42228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-12-15 05:08:51 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Sergey Biryukov
54ff178923 I18N: Make sure wp_dropdown_languages() does not print out empty name and id attributes.
Props johnjamesjacoby, afercia.
Fixes #40829.
Built from https://develop.svn.wordpress.org/trunk@41734


git-svn-id: http://core.svn.wordpress.org/trunk@41568 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 15:23:46 +00:00
Sergey Biryukov
35617e12dd I18N: In wp_dropdown_languages(), change the parsed arguments variable to $parsed_args, to prevent stomping the original $args array.
Props Mte90.
See #40829.
Built from https://develop.svn.wordpress.org/trunk@41733


git-svn-id: http://core.svn.wordpress.org/trunk@41567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 15:08:46 +00:00
John Blackbourn
28eda6f4bc General: Improve terminology used when referring to installations of WordPress and its extensions.
"Install" is not a noun, and while it might be acceptable to use the verb as a noun, it is not correct. Using the correct
noun, "installation", increases clarity, especially for non-native English speakers.

This change fixes the usage in user-facing text and in developer documentation.

Fixes #41620

Built from https://develop.svn.wordpress.org/trunk@41289


git-svn-id: http://core.svn.wordpress.org/trunk@41129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-22 11:52:48 +00:00
Drew Jaynes
6146ba0b33 Docs: Clarify the description for esc_html__() to note that the original text will be escaped on return if there is no translation, or the text domain isn't loaded.
Props brianlayman.
See #41017.

Built from https://develop.svn.wordpress.org/trunk@40932


git-svn-id: http://core.svn.wordpress.org/trunk@40782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-25 06:41:41 +00:00
Sergey Biryukov
33dc58fe70 I18N: Remove an extra slash between .mo file path and name in load_muplugin_textdomain().
Props nsundberg.
Fixes #39168.
Built from https://develop.svn.wordpress.org/trunk@40362


git-svn-id: http://core.svn.wordpress.org/trunk@40269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-01 14:26:40 +00:00
Dominik Schilling
2328e7b17a I18N: In wp_dropdown_languages() rename the new show_site_locale_default argument to show_option_site_default.
This makes it consistent with arguments of other `wp_dropdown_*()` functions.

Props SergeyBiryukov.
See #38632.
Fixes #38871.
Built from https://develop.svn.wordpress.org/trunk@39331


git-svn-id: http://core.svn.wordpress.org/trunk@39271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-21 16:14:30 +00:00
Dominik Schilling
f5b6731777 I18N: Add an additional caching layer for _load_textdomain_just_in_time().
Previously, if no translation files exist for a text domain, `_load_textdomain_just_in_time()` went through the entire process each time it was called. This results in an increased call to `get_locale()` and its `locale` filter.
This change splits the logic into `_get_path_to_translation()` and `_get_path_to_translation_from_lang_dir()`. The former, which is used by `_load_textdomain_just_in_time()`, caches the result of the latter. It also removes some non-working code from `WP_Locale_Switcher::load_translations()`.

Props jrf, swissspidy, sharkomatic, ocean90.
Fixes #37997.
Built from https://develop.svn.wordpress.org/trunk@39330


git-svn-id: http://core.svn.wordpress.org/trunk@39270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-21 16:07:33 +00:00
Dominik Schilling
a800e652c6 Docs: Apply documentation standards to the new get_available_languages filter.
See #38788.
Built from https://develop.svn.wordpress.org/trunk@39244


git-svn-id: http://core.svn.wordpress.org/trunk@39184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-15 09:52:32 +00:00
Gary Pendergast
fc1255a2c7 I18N: Add the get_available_languages filter.
Sometimes, a language file may not exist in exactly the format or location that `get_available_languages()` expects it to be in - for sites with this level of customisation, they need to be able to add their own language files to the list of those available.

Props yoavf.
Fixes #38788.


Built from https://develop.svn.wordpress.org/trunk@39235


git-svn-id: http://core.svn.wordpress.org/trunk@39175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-15 01:19:31 +00:00
Dominik Schilling
c3dc173799 I18N: Don't use get_available_languages() in _load_textdomain_just_in_time().
`get_available_languages()` is only designed to work with translations for core. Using it for plugins/themes means unnecessary `strpos()` checks and incomplete results for plugins/themes whose names are beginning with `admin-` or `ms-`.

Props swissspidy, ocean90.
Fixes #38590.
Built from https://develop.svn.wordpress.org/trunk@39230


git-svn-id: http://core.svn.wordpress.org/trunk@39170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-14 21:07:30 +00:00
Pascal Birchler
548ac82b06 I18N: Add ability to change user's locale back to site's locale.
Previously there was no way to remove the user locale setting again, even though that might be desirable.

This adds a new 'Site Default' option to the user-specific language setting by introducing a new `show_site_locale_default` argument to `wp_dropdown_languages()`.

Props ocean90.
See #29783.
Fixes #38632.
Built from https://develop.svn.wordpress.org/trunk@39169


git-svn-id: http://core.svn.wordpress.org/trunk@39109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-08 23:01:31 +00:00
Dominik Schilling
abada1fbdc I18N: In get_user_locale() ensure that $user_id isn't a falsy value before calling get_user_by().
Fixes #38485.
Built from https://develop.svn.wordpress.org/trunk@39134


git-svn-id: http://core.svn.wordpress.org/trunk@39074 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-04 17:15:26 +00:00
Pascal Birchler
b1ee6c64d9 I18N: Use the user's locale when loading text domains in the admin.
Leverages `get_user_locale()` in `load_*_textdomain()` and `_load_textdomain_just_in_time()` to always load translations in the user's language when in the admin.

This re-introduces [39069], but now with additional tests and a `function_exists( 'wp_get_current_user' )` check in `get_user_locale()` in case it gets used early.

Props swissspidy, ocean90.
Fixes #38485.
Built from https://develop.svn.wordpress.org/trunk@39127


git-svn-id: http://core.svn.wordpress.org/trunk@39067 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-04 17:11:59 +00:00
John Blackbourn
766ff15532 I18N: Revert [39069] as it needs some more work.
See #38485

Built from https://develop.svn.wordpress.org/trunk@39070


git-svn-id: http://core.svn.wordpress.org/trunk@39012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-01 16:07:32 +00:00
Pascal Birchler
8bdd37fc58 I18N: Use the user's locale when loading text domains in the admin.
Leverages `get_user_locale()` in `load_*_textdomain()` and `_load_textdomain_just_in_time()` to always load translations in the user's language when in the admin.

Fixes #38485.
Built from https://develop.svn.wordpress.org/trunk@39069


git-svn-id: http://core.svn.wordpress.org/trunk@39011 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-01 09:24:29 +00:00
Pascal Birchler
d7d8768ffd I18N: Remove unused $wpdb global from get_locale() after [39005].
Originally added in [38976], but reverted soon after.

Props johnjamesjacoby.
Fixes #38601.
Built from https://develop.svn.wordpress.org/trunk@39067


git-svn-id: http://core.svn.wordpress.org/trunk@39009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-01 07:38:31 +00:00
Dominik Schilling
a1d18b7b8a I18N: Don't initialize WP_Locale_Switcher in wp_load_translations_early().
`wp_load_translations_early()` is used when WordPress isn't fully initialized. Therefore using the `WP_Locale_Switcher` with `get_locale()`/`get_user_locale()` can cause PHP fatal errors.
This reverts [38976] and [38977], and instead removes `WP_Locale_Switcher` from `wp_load_translations_early()`.

See #29783.
Fixes #38535.
Built from https://develop.svn.wordpress.org/trunk@39005


git-svn-id: http://core.svn.wordpress.org/trunk@38947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-29 11:23:33 +00:00
Pascal Birchler
e8af4e510d I18N: Apply the locale filter when returning early in get_locale().
See [38976].
See #29783.
Built from https://develop.svn.wordpress.org/trunk@38978


git-svn-id: http://core.svn.wordpress.org/trunk@38921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-27 06:40:33 +00:00
Gary Pendergast
1c5c130af9 I18N: Fix a PHP fatal when get_locale() is called before $wpdb is ready.
If WPDB needs to bail early, it loads the translations, which need to load the locale. Without WPDB, we can't get any database options, so can only rely on what's been loaded so far.

Fixes #29783.


Built from https://develop.svn.wordpress.org/trunk@38976


git-svn-id: http://core.svn.wordpress.org/trunk@38919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-27 03:43:49 +00:00
Dominik Schilling
7819e2b4ba I18N: Introduce a locale-switching function.
With the introduction of user-specific languages in [38705] it's necessary to be able to switch translations on the fly. For example emails should be sent in the language of the recipient and not the one of the current user.

This introduces a new `WP_Locale_Switcher` class which is used for switching locales and translations. It holds the stack of locales whenever `switch_to_locale( $locale )` is called. With `restore_previous_locale()` you can restore the previous locale. `restore_current_locale()` empties the stack and sets the locale back to the initial value.

`switch_to_locale()` is added to most of core's email functions, either with the value of `get_locale()` (site language) or `get_user_locale()` (user language with fallback to site language).

Props yoavf, tfrommen, swissspidy, pbearne, ocean90.
See #29783.
Fixes #26511.
Built from https://develop.svn.wordpress.org/trunk@38961


git-svn-id: http://core.svn.wordpress.org/trunk@38904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-26 15:36:31 +00:00
Dominik Schilling
49c5fb895d I18N: Add $user_id argument to get_user_locale().
This allows to retrieve the locale of any user with the additional fallback to the site locale.

Fixes #38512.
See #29783, #26511.
Built from https://develop.svn.wordpress.org/trunk@38955


git-svn-id: http://core.svn.wordpress.org/trunk@38898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-26 14:15:32 +00:00
Pascal Birchler
4a88d55054 I18N: Introduce a user-specific language setting.
By enabling the user to select their preferred locale when editing the profile, we allow for greater personalization of the WordPress admin and therefore a better user experience.

The back end will be displayed in the user's individual locale while the locale used on the front end equals the one set for the whole site. If the user didn't specify a locale, the site's locale will be used as a fallback. The new `locale` property of the `WP_User` class can be used to retrieve the user's locale setting.

Props ocean90, ipm-frommen, swissspidy.
Fixes #29783.
Built from https://develop.svn.wordpress.org/trunk@38705


git-svn-id: http://core.svn.wordpress.org/trunk@38648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-03 07:04:29 +00:00