WordPress / wordpress-playground

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

Language switcher #199

Open adamziel opened 1 year ago

adamziel commented 1 year ago

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/

akirk commented 1 year ago

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:

And some things that you still need:

adamziel commented 1 year ago

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}}]}

Marc-pi commented 10 months ago

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 :

adamziel commented 10 months ago

A UI config/switcher would be nice indeed! CCing @akirk on that

adamziel commented 1 month ago

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.

jarekmorawski commented 1 month ago

To be clear, do you need a language switcher for sites created and managed in Playground or the new Playground UI?Both, maybe?

adamziel commented 1 month ago

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!

bgrgicak commented 1 month ago

I linked the issue to the project.