Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Performant Translations #5306

Closed
wants to merge 92 commits into from
Closed
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
c1f1b30
Add Ginger MO
swissspidy Sep 26, 2023
eca1b03
Merge branch 'WordPress:trunk' into add/ginger-mo
swissspidy Sep 26, 2023
c511e7e
Merge branch 'trunk' into add/ginger-mo
swissspidy Oct 3, 2023
227a422
Fix conditionals
swissspidy Oct 3, 2023
17a5c6e
Add realpath
swissspidy Oct 3, 2023
4fadb69
Add PHPUnit tests
swissspidy Oct 3, 2023
7af8b63
Lint fixes
swissspidy Oct 3, 2023
95d32ea
Check if is string
swissspidy Oct 3, 2023
1d0845b
Merge branch 'trunk' into add/ginger-mo
swissspidy Oct 5, 2023
f3e76b2
Remove json support and upgrader integration
swissspidy Oct 5, 2023
b474eb2
Remove some more files
swissspidy Oct 5, 2023
3e28624
Remove unlink
swissspidy Oct 5, 2023
fad8459
Delete PHP translation file on plugin uninstall
swissspidy Oct 5, 2023
1d7964a
Add back one file that’s actually used
swissspidy Oct 5, 2023
81b7cef
Merge branch 'trunk' into add/ginger-mo
swissspidy Oct 13, 2023
72e8013
Merge branch 'trunk' into add/ginger-mo
swissspidy Oct 13, 2023
02cdf17
Merge branch 'trunk' into add/ginger-mo
swissspidy Oct 18, 2023
3e5e344
docblock updates
swissspidy Oct 18, 2023
8064c47
More doc updates
swissspidy Oct 18, 2023
af09604
Merge branch 'trunk' into add/ginger-mo
swissspidy Oct 19, 2023
fb70136
Rename classes
swissspidy Oct 19, 2023
c658b3f
Rename var
swissspidy Oct 19, 2023
a33ae17
Fix alignment
swissspidy Oct 19, 2023
922966c
Fix test
swissspidy Oct 19, 2023
6e38a35
Merge branch 'trunk' into add/ginger-mo
swissspidy Oct 26, 2023
1aee1fa
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 8, 2023
2010f07
Merge latest change from plugin
swissspidy Nov 8, 2023
05b3044
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 8, 2023
00e7bcf
Fix alignment
swissspidy Nov 8, 2023
3ed966e
Apply some suggestions from code review
swissspidy Nov 8, 2023
841821a
Fix `@subpackage` annotations
swissspidy Nov 9, 2023
009bca8
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 10, 2023
38e607d
Use loop, update docs
swissspidy Nov 10, 2023
d816760
Pass i18n controller instance to `WP_I18N_Translations`
swissspidy Nov 10, 2023
42e5f44
Drop `_i18n_` infix
swissspidy Nov 10, 2023
a52e153
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 10, 2023
f9a0337
Docblock improvements
swissspidy Nov 10, 2023
3344c31
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 10, 2023
b46509f
Revert accidental change
swissspidy Nov 10, 2023
b33a83f
Rename test files
swissspidy Nov 10, 2023
86a84fc
Add missing parent call
swissspidy Nov 10, 2023
e572b0c
Simplify unloading
swissspidy Nov 11, 2023
d1d1ec9
Rename parameter
swissspidy Nov 11, 2023
eae66c6
Improve cleanup in other test
swissspidy Nov 11, 2023
12e0a25
Avoid leaky tests with multiple interfering class instances
swissspidy Nov 11, 2023
c16d995
move unload higher up
swissspidy Nov 11, 2023
ddd339a
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 11, 2023
3fd0424
Add test for e572b0c234d1d5cdf838b00637e0bb945474fb73
swissspidy Nov 12, 2023
163ca24
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 12, 2023
d608621
Rename `.mo.php` to `.l10n.php`
swissspidy Nov 12, 2023
e457732
Docblock improvements
swissspidy Nov 13, 2023
00349f1
Merge branch 'trunk' into add/ginger-mo-fix-ext
swissspidy Nov 13, 2023
d779fd3
Merge branch 'trunk' into add/ginger-mo
swissspidy Nov 22, 2023
a0710ce
Add text domain to `translation_file_format` filter
swissspidy Nov 22, 2023
2d9297b
Merge branch 'trunk' into add/ginger-mo
swissspidy Dec 21, 2023
6a391d1
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 11, 2024
a105e68
Merge pull request #50 from swissspidy/add/ginger-mo-fix-ext
swissspidy Jan 15, 2024
08fac98
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 15, 2024
6309d09
Minor adjustments
swissspidy Jan 15, 2024
c418a3d
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 15, 2024
8914c25
Another minor docblock change
swissspidy Jan 15, 2024
3b1f7b9
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 16, 2024
7f2365a
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 17, 2024
8cf9742
Add back return types
swissspidy Jan 17, 2024
bed7187
Rename method
swissspidy Jan 17, 2024
2e9382b
Remove errant return type again
swissspidy Jan 17, 2024
2cbda5b
Apply suggestions from code review
swissspidy Jan 17, 2024
ba412b0
Apply suggestions from code review
swissspidy Jan 17, 2024
b2b98e9
Lint fix
swissspidy Jan 17, 2024
6df6c51
Return false if nothing unloaded
swissspidy Jan 17, 2024
ad57b5c
use `substr_replace`
swissspidy Jan 17, 2024
6cc6397
Add return type
swissspidy Jan 17, 2024
aa2f842
fix phpdoc
swissspidy Jan 17, 2024
d13731b
String errors
swissspidy Jan 17, 2024
bf1a7a9
Array shape
swissspidy Jan 17, 2024
5702b59
Update error messages in tests
swissspidy Jan 17, 2024
19c7bc3
Apply suggestion
swissspidy Jan 17, 2024
0e8f5a1
Bundled Themes: Typo corrections in various themes docblocks.
audrasjb Jan 17, 2024
b45415e
Twenty Twenty: Replace `wp_date()` with `date_i18n()`.
audrasjb Jan 17, 2024
06939be
Docs: Fix var types of parameters in `sanitize_option()` and `sanitiz…
audrasjb Jan 17, 2024
5312510
I18N: Prevent PHP warning in `WP_Textdomain_Registry`.
swissspidy Jan 17, 2024
3884032
Twenty Twenty-Four: Remove extra tab character inside the text domain.
SergeyBiryukov Jan 17, 2024
54869c7
I18N: Fix duplicate `determine_locale()` tests added in [57286].
swissspidy Jan 17, 2024
5698536
Fix phpdoc
swissspidy Jan 17, 2024
d35b430
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 19, 2024
5fae127
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 22, 2024
726357f
Move compat function closer to others
swissspidy Jan 22, 2024
f32eb49
Correcting the class name capitalization and adding brackets for the …
swissspidy Jan 22, 2024
f06a84a
Update docblocks as per feedback
swissspidy Jan 22, 2024
d603381
Fix description
swissspidy Jan 22, 2024
8e9a8a8
Do not change `temp_filename` signature
swissspidy Jan 23, 2024
9012b94
Merge branch 'trunk' into add/ginger-mo
swissspidy Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-admin/includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ function delete_plugins( $plugins, $deprecated = '' ) {
foreach ( $translations as $translation => $data ) {
$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' );
$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' );
$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo.php' );
swissspidy marked this conversation as resolved.
Show resolved Hide resolved

$json_translation_files = glob( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '-*.json' );
if ( $json_translation_files ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-locale-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ private function change_locale( $locale ) {

$wp_locale = new WP_Locale();

WP_Translation_Controller::instance()->set_locale( $locale );

/**
* Fires when the locale is switched to or restored.
*
Expand Down
32 changes: 32 additions & 0 deletions src/wp-includes/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,35 @@ function str_ends_with( $haystack, $needle ) {
if ( ! defined( 'IMG_WEBP' ) ) {
define( 'IMG_WEBP', IMAGETYPE_WEBP );
}

if ( ! function_exists( 'array_is_list' ) ) {
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
/**
* Polyfill for `array_is_list()` function added in PHP 8.1.
*
* Determines if the given array is a list.
*
* An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1.
*
* @see https://github.com/symfony/polyfill-php81/tree/main
*
* @since 6.5.0
*
* @param array<mixed> $arr The array being evaluated.
* @return bool True if array is a list, false otherwise.
*/
function array_is_list( $arr ) {
if ( ( array() === $arr ) || ( array_values( $arr ) === $arr ) ) {
return true;
}

$next_key = -1;

foreach ( $arr as $k => $v ) {
if ( ++$next_key !== $k ) {
return false;
}
}

return true;
}
}
2 changes: 1 addition & 1 deletion src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6533,7 +6533,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) {
if ( ! $mo_loaded || $locale !== $locale_loaded ) {
$locale_loaded = $locale ? $locale : get_locale();
$mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
unload_textdomain( 'continents-cities' );
unload_textdomain( 'continents-cities', true );
load_textdomain( 'continents-cities', $mofile, $locale_loaded );
$mo_loaded = true;
}
Expand Down
Loading
Loading