Commit Graph

152 Commits

Author SHA1 Message Date
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
Scott Taylor 3f51e08ac6 i18n: after r38364, check that `global $wp_locale` is an instance of `WP_Locale` before calling `->is_rtle()` in `is_rtl()`.
See #37827.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38379 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 05:57:41 +00:00
Scott Taylor 6d87157eb9 i18n: move `is_rtl()` to `l10n.php` (which loads way earlier). Load `WP_Locale` file in `wp-settings.php`. Retire `wp-includes/locale.php` - it only loaded the class and the one function, `is_rtl()`. If someone loaded this file for fun somewhere else, it would be a fatal error.
See #37827.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38305 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 10:20:29 +00:00
Scott Taylor ac6c22c392 L10N: improve accuracy of docs.
Props johnbillion.
Fixes #37585.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 09:38:28 +00:00
Sergey Biryukov 83bed74a2f Docs: Fix typo in `load_plugin_textdomain()` parameter description.
Props tivnet.
See #37318.
Built from https://develop.svn.wordpress.org/trunk@38284


git-svn-id: http://core.svn.wordpress.org/trunk@38225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-19 14:29:30 +00:00
John Blackbourn dc3d64ed9c I18N: Correct the documented return types of `get_translations_for_domain()`.
See #32246

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


git-svn-id: http://core.svn.wordpress.org/trunk@38139 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-04 22:13:29 +00:00
Drew Jaynes 6cc13f0c54 Docs: Fix formatting, tense, verb conjugation, and other syntax for wp-includes/* elements introduced or changed in 4.6.
Part 1/2.

See #37318.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-20 16:57:32 +00:00
Sergey Biryukov 139387b7e5 Docs: Use 3-digit, x.x.x-style semantic versioning for `_doing_it_wrong()`, `_deprecated_function()`, `_deprecated_argument()`, and `_deprecated_file()` throughout core.
Props metodiew.
Fixes #36495.
Built from https://develop.svn.wordpress.org/trunk@37985


git-svn-id: http://core.svn.wordpress.org/trunk@37926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-06 12:40:29 +00:00
Jeremy Felt 6f3f00ea97 Multisite: Change `WP_Network` `id` property to an integer.
For consistency and developer sanity.

Props flixos90.
Fixes #37050.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-26 14:26:29 +00:00
Drew Jaynes 558d5b371c Docs: Standardize filter docs in wp-includes/l10n.php to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:48:28 +00:00
Dominik Schilling a673a71f94 I18N: In `get_translations_for_domain()` check if the global `$l10n` was set by `_load_textdomain_just_in_time()` before accessing it.
Props danielhuesken.
Fixes #34114.
Built from https://develop.svn.wordpress.org/trunk@37440


git-svn-id: http://core.svn.wordpress.org/trunk@37406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-16 15:10:29 +00:00
Pascal Birchler 64fb1a9e90 I18N: Add changes missed in [37415].
See #34114.
Built from https://develop.svn.wordpress.org/trunk@37416


git-svn-id: http://core.svn.wordpress.org/trunk@37382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-10 20:31:27 +00:00
Pascal Birchler 3f6966907b I18N: Reverse the order of loading plugin and theme translations.
`load_theme_textdomain()`, `load_plugin_textdomain()` and `load_muplugin_textdomain()` now try to load the .mo file from the `wp-content/languages` directory first. After the introduction of language packs, translation files are more likely to be located there.

Props swissspidy, sebastian.pisula.
Fixes #34213.
Built from https://develop.svn.wordpress.org/trunk@37414


git-svn-id: http://core.svn.wordpress.org/trunk@37380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-10 18:50:27 +00:00
Drew Jaynes fe3b007fdd Docs: Remove inline `@see` tags from function, class, and method references in inline docs.
Known functions, classes, and methods are now auto-linked in Code Reference pages following #meta1483.

Note: Hook references are still linked via inline `@see` tags due to the unlikelihood of reliably matching for known hooks based on a RegEx pattern.

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-02 04:00:28 +00:00
Sergey Biryukov 7c2ad56158 Docs: Correct description for `override_load_textdomain` and `override_unload_textdomain` filters.
Props dimadin.
Fixes #36537.
Built from https://develop.svn.wordpress.org/trunk@37214


git-svn-id: http://core.svn.wordpress.org/trunk@37180 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-15 17:19:28 +00:00
Sergey Biryukov bd4c250078 Docs: Correct `_n_noop()` and `_nx_noop()` descriptions to use third-person singular verbs.
Props realloc.
See #35961.
Built from https://develop.svn.wordpress.org/trunk@36765


git-svn-id: http://core.svn.wordpress.org/trunk@36732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-28 20:43:26 +00:00
Dominik Schilling 51473acfb3 i18n: Prevent `is_textdomain_loaded()` from returning true even if there are no translations for the domain.
In `get_translations_for_domain()` don't fill the global `$l10n` with `NOOP_Translations` instances, return a `NOOP_Translations` instance instead.

Props nacin, jrf.
Fixes #21319.
Built from https://develop.svn.wordpress.org/trunk@36538


git-svn-id: http://core.svn.wordpress.org/trunk@36505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-16 21:15:29 +00:00
John Blackbourn 045d7d3a18 I18N: Correct an argument description and return value for `wp_dropdown_languages()`.
Props realloc
See #35294

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


git-svn-id: http://core.svn.wordpress.org/trunk@36257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-13 20:33:25 +00:00
Drew Jaynes 9b89047bf2 Docs: Add a missing notation for the `$context` parameter in the DocBlock for `_nx_noop()`.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35977 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-18 23:16:26 +00:00
Sergey Biryukov 6ffc7914f1 I18N: Add a unit test for `before_last_bar()`.
Props realloc.
Fixes #35073.
Built from https://develop.svn.wordpress.org/trunk@35959


git-svn-id: http://core.svn.wordpress.org/trunk@35923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-16 08:04:26 +00:00
Dominik Schilling 6fb81e3338 L10n: Use an absolute path for the `is_dir()` check when looking for installed translations.
Avoids warnings when `open_basedir` restrictions are in effect.

Props Profforg.
Fixes #34526.
Built from https://develop.svn.wordpress.org/trunk@35856


git-svn-id: http://core.svn.wordpress.org/trunk@35820 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-10 23:09:27 +00:00
Jeremy Felt 9926983b66 Revert [34778], continue using `_site_option()` for the current network.
The `_network_option()` parameter order will be changing to accept `$network_id` first. The `_site_option()` functions will remain in use throughout core as our way of retrieving a network option for the current network.

See #28290.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34877 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 17:11:25 +00:00
Boone Gorges 0e7c1d3b14 Use `wp_installing()` instead of `WP_INSTALLING` constant.
The `WP_INSTALLING` constant is a flag that WordPress sets in a number of
places, telling the system that options should be fetched directly from the
database instead of from the cache, that WP should not ping wordpress.org for
updates, that the normal "not installed" checks should be bypassed, and so on.

A constant is generally necessary for this purpose, because the flag is
typically set before the WP bootstrap, meaning that WP functions are not yet
available.  However, it is possible - notably, during `wpmu_create_blog()` -
for the "installing" flag to be set after WP has already loaded. In these
cases, `WP_INSTALLING` would be set for the remainder of the process, since
there's no way to change a constant once it's defined. This, in turn, polluted
later function calls that ought to have been outside the scope of site
creation, particularly the non-caching of option data. The problem was
particularly evident in the case of the automated tests, where `WP_INSTALLING`
was set the first time a site was created, and remained set for the rest of the
suite.

The new `wp_installing()` function allows developers to fetch the current
installation status (when called without any arguments) or to set the
installation status (when called with a boolean `true` or `false`). Use of
the `WP_INSTALLING` constant is still supported; `wp_installing()` will default
to `true` if the constant is defined during the bootstrap.

Props boonebgorges, jeremyfelt.
See #31130.
Built from https://develop.svn.wordpress.org/trunk@34828


git-svn-id: http://core.svn.wordpress.org/trunk@34793 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-05 15:06:28 +00:00
Drew Jaynes bfa2a5295e Docs: Improve a variety of inline docs in wp-includes/l10n.php.
* Corrects phrasing used in the descriptions for and filters in `_n()` and `_nx()`, particularly with regard to the use of 'singular' instead of 'single' or '1', and 'plural' instead of 'not 1'.
* Adds example usage to `_n()`, `_nx()`, `_nx_noop()`, and `translate_nooped_plural()`.
* Adds hash notation `@return` doc for `_n_noop()` and `_nx_noop()`.
* Adds missing default values for the optional `$domain` parameter in several places.

Props johnbillion.
Fixes #34127.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34746 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-02 20:45:24 +00:00
Jeremy Felt 54512d64cb MS: Use `*_network_option()` functions throughout core.
Replaces all uses of `*_site_option()` with the corresponding "network" function.

This excludes one usage in `wp-admin/admin-footer.php` that needs more investigation.

Props spacedmonkey.
See #28290.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-02 19:08:26 +00:00
Drew Jaynes e5e03e787c Docs: Link up a hook reference with an inline `@see` tag in the return description for `get_locale()`.
Missed in [34484].

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 05:51:23 +00:00
Drew Jaynes 81e135955a Docs: Fix the summary for `get_locale()`.
Also update the description to properly link up hook references with inline `@see` tags.

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34448 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 05:50:24 +00:00
Drew Jaynes 1c761505b6 Docs: Clarify the file header summary for wp-includes/l10n.php and add the version it was introduced.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 05:47:24 +00:00
Drew Jaynes f64c19aa95 Docs: Split the DocBlock summary for `__()` into a summary and description.
Also, notate the default value for the optional `$domain` parameter.

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 05:43:26 +00:00
Scott Taylor ef87172270 `foreach` is a statement, not a function.
See #33491.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 20:28:22 +00:00
Mark Jaquith 4965581097 Don't blindly trust the output of `glob()` to be an array.
props kitchin
fixes #33093
Built from https://develop.svn.wordpress.org/trunk@33447


git-svn-id: http://core.svn.wordpress.org/trunk@33414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-27 18:05:24 +00:00
Drew Jaynes 71a7b8c5a4 Remove now-unnecessary inline `@see` tag from the DocBlock for `wp_dropdown_languages()`.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33202 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:42:24 +00:00
Dominik Schilling 699dbedb03 l10n: Update `wp_get_installed_translations()` to support variants of a language.
* A variant of a language has its own locale, for example the locale of the formal variant of German is `de_DE_formal`.
* Update `remove_accents()` and some CSS rules to support `de_DE_formal`.
* Add tests for `get_bloginfo( 'language' )`.
* API changes will be deployed over the next few days.

see #28303.
Built from https://develop.svn.wordpress.org/trunk@33027


git-svn-id: http://core.svn.wordpress.org/trunk@32998 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-01 15:43:24 +00:00
Scott Taylor b9e8ee95b5 `prep_atom_text_construct()` and `before_last_bar()` should strictly check against `false` when using `str(r)?pos()`.
Sidenote: there's a function named `before_last_bar`.

See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32911 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-25 16:49:25 +00:00
Scott Taylor 2787e0080a Add missing doc blocks to `l10n.php`
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-26 18:13:25 +00:00
Sergey Biryukov d40fe7d80b Allow `wp_dropdown_languages()` to return the markup instead of displaying.
props leewillis77, juliobox.
fixes #32432.
Built from https://develop.svn.wordpress.org/trunk@32510


git-svn-id: http://core.svn.wordpress.org/trunk@32480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-19 00:33:26 +00:00
Sergey Biryukov e2f5a8094e Avoid a PHP notice in `wp_install_language_form()` and `wp_dropdown_languages()` if the language doesn't have a ISO 639-1 code.
props barrykooij.
fixes #31319.
Built from https://develop.svn.wordpress.org/trunk@31447


git-svn-id: http://core.svn.wordpress.org/trunk@31428 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-13 11:23:26 +00:00
Scott Taylor 60b0cd7943 The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.
This was a mess, is now standardized across the codebase, except for a few 3rd-party libs. 

See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 07:05:25 +00:00
Scott Taylor a0df295f5c Improve various `@param` docs.
See #30224.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 23:24:25 +00:00
Drew Jaynes b8c612ca1c Ensure inline code is markdown-escaped as such, HTML tags are removed from summaries, and that code snippets in descriptions are properly indented.
Affects DocBlocks for the following core elements:
* Markdown-indent a code snippet in the file header for wp-admin/install-helper.php
* Add markdown formatting and two inline `@see` tags to the description for `translate()`
* Markdown-indent a code snippet in the description for `_n_noop()`
* Remove HTML tags from the summary for `get_media_embedded_in_content()`
* Remove an HTML tag from the summary for `wpview_media_sandbox_styles()`

Props rarst.
See #30473.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-24 05:47:23 +00:00
John Blackbourn 3ace1fac81 Only output an optgroup for installed languages in `wp_dropdown_languages()` if translations are available.
See #30335

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


git-svn-id: http://core.svn.wordpress.org/trunk@30484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 03:20:22 +00:00
Drew Jaynes 51e7e8e695 Clarify/correct inline documentation in wp-includes/l10n.php.
* Add a missing `@return` description for `load_default_textdomain()`
* Clarify the `@param` description for `$locale` with an inline `@see` tag
* Ensure the correct parameter variable is used when documenting `$args` for `wp_dropdown_languages()`

Props camdensegal.
Fixes #30385.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-18 18:47:22 +00:00
Andrew Nacin b922be3f71 Only use the 'Installed' optgroup in wp_dropdown_languages() if it's needed.
see #30335.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30339 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-14 03:24:23 +00:00
Dominik Schilling 8fb6f317ff Site Language: Install translations on the fly.
The language dropdown now includes installed languages and all available translations when the filesystem is writable by WordPress.
Go to wp-admin/options-general.php, select one of the available translations, submit the form and let WordPress handle the rest.
Works for Multisite's Default Language too.

see #29395.
Built from https://develop.svn.wordpress.org/trunk@30335


git-svn-id: http://core.svn.wordpress.org/trunk@30334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-13 17:01:24 +00:00
John Blackbourn ae7cb843a0 Avoid double path separators in `load_theme_textdomain()`. Fixes #29122. Props bradyvercher
Built from https://develop.svn.wordpress.org/trunk@29984


git-svn-id: http://core.svn.wordpress.org/trunk@29726 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-21 17:58:18 +00:00
Dominik Schilling 57c41263d7 Language packs: Remove translations when deleting a theme or a plugin.
This is for translation files in WP_LANG_DIR which are installed through a language pack.
Change `wp_get_installed_translations()` to only return a translation if the .mo file also exists.

fixes #29860.
Built from https://develop.svn.wordpress.org/trunk@29856


git-svn-id: http://core.svn.wordpress.org/trunk@29619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 19:05:20 +00:00