wordpress-playground
wordpress-playground copied to clipboard
Language switcher
Let's add a UI control to switch Playground to another language. Here's how @akirk does it in his GlotPress integration project:
https://github.com/akirk/wp-glotpress-playground/
The meat is here: https://github.com/akirk/wp-glotpress-playground/blob/ab5942aceed309c3f87db2b8fe26d781d199aeb4/index.php#L76-L85
There are some things that you don't need for a "normal" install:
- PO files. WordPress displays MO files.
And some things that you still need:
- JSON translation files for Gutenberg.
Oki so languages are supported via Blueprints. Playground just needs a documentation page and maybe a handy language picker in the settings modal that would apply the Blueprint for the user.
For example, a Blueprint to run WordPress with Japanese translations:
{
"landingPage":"/wp-admin/?welcome=0",
"steps":[
{
"step":"login",
"username":"admin",
"password":"password"
},
{
"step":"mkdir",
"path":"/wordpress/wp-content/languages/plugins"
},
{
"step":"mkdir",
"path":"/wordpress/wp-content/languages/themes"
},
{
"step":"writeFile",
"path":"/wordpress/wp-content/languages/ja_JA.mo",
"data":{
"resource":"url",
"caption":"Downloading ja_JA.mo",
"url":"https://translate.wordpress.org/projects/wp/dev/ja/default/export-translations?format=mo"
}
},
{
"step":"writeFile",
"path":"/wordpress/wp-content/languages/admin-ja_JA.mo",
"data":{
"resource":"url",
"caption":"Downloading admin-ja_JA.mo",
"url":"https://translate.wordpress.org/projects/wp/dev/admin/ja/default/export-translations?format=mo"
}
},
{
"step":"setSiteOptions",
"options":{
"WPLANG":"ja_JA"
}
}
]
}
To use it, put the above behind a hash #
as follows:
https://playground.wordpress.net/#{%22landingPage%22:%22/wp-admin/?welcome=0%22,%22steps%22:[{%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22},{%22step%22:%22mkdir%22,%22path%22:%22/wordpress/wp-content/languages/plugins%22},{%22step%22:%22mkdir%22,%22path%22:%22/wordpress/wp-content/languages/themes%22},{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/languages/ja_JA.mo%22,%22data%22:{%22resource%22:%22url%22,%22caption%22:%22Downloading%20ja_JA.mo%22,%22url%22:%22https://translate.wordpress.org/projects/wp/dev/ja/default/export-translations?format=mo%22}},{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/languages/admin-ja_JA.mo%22,%22data%22:{%22resource%22:%22url%22,%22caption%22:%22Downloading%20admin-ja_JA.mo%22,%22url%22:%22https://translate.wordpress.org/projects/wp/dev/admin/ja/default/export-translations?format=mo%22}},{%22step%22:%22setSiteOptions%22,%22options%22:{%22WPLANG%22:%22ja_JA%22}}]}
yep, that's a need to be able to run the Playground in other languages than English. the doc https://wordpress.github.io/wordpress-playground/faq/#is-wordpress-playground-available-in-another-language
Solutions :
-
add a config within the Playground Customize
-
add a switcher like the default WP (see settings)
-
improve /fix the doc see https://github.com/WordPress/wordpress-playground/issues/723
A UI config/switcher would be nice indeed! CCing @akirk on that
cc @jarekmorawski – would this be easy to incorporate in the WebApp redesign? If yes, would you be up for adding a widget somewhere? If it turns out to be tricky for any reason, let's save it for the future.
To be clear, do you need a language switcher for sites created and managed in Playground or the new Playground UI?Both, maybe?
Just whenever you create a new site within Playground, right next to the PHP version picker. I've seen that in Figma so I think we're good here design-wise and only need to incorporate this in the new implementation. Thank you!
I linked the issue to the project.