How will translations be handled in block based themes? #21204
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
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?
The text was updated successfully, but these errors were encountered: