forked from WordPress/wordpress-playground
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Blueprints] setSiteLanguage step – download the latest RC translatio…
…ns for Nightly and Beta builds of WordPress (WordPress#1987) This PR enables using `setSiteLanguage` with beta and nightly WordPress versions: ```json { "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 came directly from WordPress's version.php. However, the WordPress translations API only offers translations for released versions of WordPress (e.g. `6.6`, `6.6.1`) and one RC translation for each minor version (e.g. `6.6-RC`, `6.7-RC`). Beta, and RC versions of WordPress all use a single RC translation version. Development, versions don't have a translation version, 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) - CI ### Manual testing instructions - Open Nightly in Spanish http://127.0.0.1:5400/website-server/?wp=nightly&language=es_ES&url=%2Fwp-admin%2F - Confirm WP-admin is in Spanish - Open Beta in Spanish http://127.0.0.1:5400/website-server/?wp=beta&language=es_ES&url=%2Fwp-admin%2F - Confirm WP-admin is in Spanish - Open 6.5 in Spanish http://127.0.0.1:5400/website-server/?wp=6.5&language=es_ES&url=%2Fwp-admin%2F - Confirm WP-admin is in Spanish --------- Co-authored-by: Adam Zieliński <[email protected]>
- Loading branch information
Showing
5 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/playground/blueprints/src/lib/steps/set-site-language.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { MinifiedWordPressVersions } from '@wp-playground/wordpress-builds'; | ||
import { getWordPressTranslationUrl } from './set-site-language'; | ||
|
||
describe('getTranslationUrl()', () => { | ||
it('should return a major.minor translation URL for a major.minor version', () => { | ||
expect(getWordPressTranslationUrl('6.6', 'en_US')).toBe( | ||
'https://downloads.wordpress.org/translation/core/6.6/en_US.zip' | ||
); | ||
}); | ||
|
||
it('should return a major.minor.patch translation URL for a major.minor.patch version', () => { | ||
expect(getWordPressTranslationUrl('6.5.1', 'es_ES')).toBe( | ||
'https://downloads.wordpress.org/translation/core/6.5.1/es_ES.zip' | ||
); | ||
}); | ||
|
||
[ | ||
{ | ||
version: '6.6-RC1', | ||
description: | ||
'should return the latest RC translation URL for a RC version', | ||
}, | ||
{ | ||
version: '6.6-beta2', | ||
description: | ||
'should return the latest RC translation URL for a beta version', | ||
}, | ||
{ | ||
version: '6.6-nightly', | ||
description: | ||
'should return the latest RC translation URL for a nightly version', | ||
}, | ||
{ | ||
version: '6.8-alpha-59408', | ||
description: | ||
'should return the latest RC translation URL for an alpha version', | ||
}, | ||
].forEach(({ version, description }) => { | ||
it(description, () => { | ||
const latestBetaVersion = | ||
MinifiedWordPressVersions['beta'].split('-')[0]; | ||
expect(getWordPressTranslationUrl(version, 'en_US')).toBe( | ||
`https://downloads.wordpress.org/translation/core/${latestBetaVersion}-RC/en_US.zip` | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters