Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How will translations be handled in block based themes? #21204

Open
wpscholar opened this issue Mar 27, 2020 · 2 comments
Open

How will translations be handled in block based themes? #21204

wpscholar opened this issue Mar 27, 2020 · 2 comments
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Internationalization (i18n) Issues or PRs related to internationalization efforts

Comments

@wpscholar
Copy link
Member

wpscholar commented Mar 27, 2020

Given that block based theme templates are HTML files as opposed to PHP files, the traditional way of handling translations is not viable. While the I18N package appears to be at first glance a viable option for translating strings within HTML, it would require wrapping all strings in <script> tags so that we can run the JavaScript necessary to do the translating. However, there is a reason that no _e() function exists in that library… because outputting text in place isn’t a best practice. As such, we would need to lean on more JavaScript tooling to get the job done. Very likely, we may need to leverage a framework like React to make managing the output of these strings easier. Or, we could just use PHP. Any blocks within the WordPress loop are going to have to be server rendered anyway.

As a result of this likely shift to using JavaScript to render our translations, we will likely run into search engine optimization issues. Our usage of React thus far hasn’t had to take SEO into account. Most developers assume that content rendered with JavaScript is crawlable by the search engines, but the reality is that Google still struggles with this. In my experience, it is still a best practice to server render. I’m also unsure what the impact would be on accessibility.

What is the plan for handling translations in block based themes?

@wpscholar wpscholar added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Internationalization (i18n) Issues or PRs related to internationalization efforts [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Mar 27, 2020
@ockham
Copy link
Contributor

ockham commented Apr 20, 2020

Block context might provide a solution for this issue, see #20966 (comment).

@ockham
Copy link
Contributor

ockham commented Apr 20, 2020

Related: #21728

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Internationalization (i18n) Issues or PRs related to internationalization efforts
Projects
None yet
Development

No branches or pull requests

2 participants