WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.65k stars 263 forks source link

[Blueprints] setSiteLanguage step – download the latest RC translations for Nightly and Beta builds of WordPress #1987

Closed bgrgicak closed 6 days ago

bgrgicak commented 2 weeks ago

This PR enables using setSiteLanguage with beta and nightly WordPress versions:

{
    "preferredVersions": {
        "php": "8.0",
        "wp": "beta"
    },
    "steps": [
        {
            "step": "setSiteLanguage",
            "language": "en_GB"
        }
    ]
}

Before this PR, the above Blueprint would fetch translations from https://downloads.wordpress.org/translation/core/6.7-RC2/es_ES.zip and fail after a 404 API response from the WordPress.org translations API. The 6.7-RC2 version string in the URL came directly from WordPress's version.php.

The WordPress translations API only offers translations for full, official WordPress releases (e.g. 6.6, 6.6.1) plus RC translations for each major WordPress version (e.g. 6.6-RC, 6.7-RC). Note that beta and RC versions use the same translations bundle. Also, there is no translation bundle for the development versions so the best we can do is download the latest RC translations.

This PR transforms the raw version string, such as 6.7-RC2 or 6.8-alpha-59341, into one recognized by the API, such as 6.7-RC or 6.8-RC. As a result, the above Blueprint now fetches the translations from https://downloads.wordpress.org/translation/core/6.7-RC/es_ES.zip.

Testing Instructions (or ideally a Blueprint)

Manual testing instructions

adamziel commented 13 hours ago

This PR created a dependency between the Blueprints package and the WordPress builds package. @bgrgicak let's pull the WordPress version details from api.wordpress.org/core/version-check/1.7?channel=beta instead of using the version of the latest minified web build the web as a proxy for the latest WordPress version.

adamziel commented 12 hours ago

The resolveWPRelease CLI function might be ripe for reuse in the Blueprints library. That's one less Playground CLI-specific code path.