Make WordPress Core


Ignore:
Timestamp:
04/30/2024 08:37:25 AM (10 months ago)
Author:
swissspidy
Message:

I18N: Actually add all the files for [58061], not just the test fixtures.

Improve support for using only PHP translation files.

This builds on top of the PHP translation file support added in WordPress 6.5, improving the behavior for projects using solely .l10n.php translation files and no .mo. and .po files.

Updates wp_get_installed_translations(), which is used when updating language packs and when uninstalling plugins/themes (to remove the translations again), to look for PHP translation files and read metadata from them. Additionally, the file lookup is now cached thanks to using WP_Textdomain_Registry.

Updates Language_Pack_Upgrader::check_package() to allow language packs that only contain PHP translation files. While WordPress.org continues to serve .mo and .po files, third-party services might want to only use the PHP file format.

See #60554.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/l10n.php

    r54365 r58062  
    7171
    7272        $array = get_available_languages( DIR_TESTDATA . '/languages/' );
    73         $this->assertSame( array( 'de_DE', 'en_GB', 'es_ES', 'ja_JP' ), $array );
     73        $this->assertEqualSets(
     74            array(
     75                'de_DE',
     76                'en_GB',
     77                'es_ES',
     78                'ja_JP',
     79                'de_CH',
     80            ),
     81            $array
     82        );
    7483    }
    7584
    7685    /**
    7786     * @ticket 35284
     87     * @ticket 60554
    7888     *
    7989     * @covers ::wp_get_installed_translations
     90     * @covers ::wp_get_pomo_file_data
     91     * @covers ::wp_get_l10n_php_file_data
    8092     */
    8193    public function test_wp_get_installed_translations_for_core() {
     
    96108        $this->assertSame( 'Administration', $data_es_es['Project-Id-Version'] );
    97109        $this->assertSame( 'Poedit 1.8.10', $data_es_es['X-Generator'] );
     110
     111        $this->assertNotEmpty( $installed_translations['default']['de_CH'] );
     112        $data_en_gb = $installed_translations['default']['de_CH'];
     113        $this->assertSame( '2024-01-31 19:08:22+0000', $data_en_gb['PO-Revision-Date'] );
     114        $this->assertSame( 'WordPress - 6.4.x - Development', $data_en_gb['Project-Id-Version'] );
     115        $this->assertSame( 'GlotPress/4.0.0-beta.2', $data_en_gb['X-Generator'] );
    98116    }
    99117
Note: See TracChangeset for help on using the changeset viewer.