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

Create localized versions of the templates and template parts #46

Open
5 tasks done
bobbingwide opened this issue Nov 30, 2020 · 4 comments
Open
5 tasks done

Create localized versions of the templates and template parts #46

bobbingwide opened this issue Nov 30, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Nov 30, 2020

Full Site Editing themes should support internationalization (i18n) and localization (l10n).

The process to extract and localize is summarized by this diagram.

screenshot

Requirements

  • To be able to use the Fizzie theme in the user's selected locale.
  • To automatically extract and localize templates and template parts.
  • Test with two additional languages:
  1. UK English - locale en_GB
  2. bbboing's language bb_BB

Proposed solution

Requirements on Gutenberg

  • Gutenberg's template and template loading logic needs to be updated to take into account the user's locale.
  • The translated files will be stored in subfolders of the languages folder, with one directory per supported locale.
  • If the directory isn't present the US English files are used.

Assumptions, scope, exclusions and caveats

  • Templates and template parts are inherently static; they don't implement conditional / looping logic.
  • Internationalization (i18n) of the templates and template parts is only necessary for certain strings which should not be translated.
  • As such, localized versions can be created at build time, or whenever the translations are updated.
  • Blocks used in templates and template parts may implement conditional / looping logic.
  • These blocks are usually server side rendered using PHP.
  • A theme's PHP code will be localized using makepot.
  • Any JavaScript blocks delivered by the theme will be localized using makejson.
  • The solution should support all locales and character sets currently supported by WordPress.
  • The solution should support themes which are not delivered from wordpress.org

Limitations of the prototyped solution

  • t10n.bat is currently dependent upon oik-batch's oik
  • The current routines are prototyped batch routines which echo debug information.
  • Not all scenarios are yet catered for by the routines invoked by t10n.
  • The current solution doesn't merge .pot files into one file prior to translation.
  • But text strings used in PHP and template files and parts are not expected to be the same.
  • So there shouldn't be too many duplicate strings to translate.
@bobbingwide
Copy link
Owner Author

I've created a new version of the extraction and localization routines in bobbingwide/oik-i18n/issues/9 which now supports extraction translation and localization of rich text strings. These changes need to be tested in Fizzie before the Gutenberg proposal is updated.

@bobbingwide
Copy link
Owner Author

t10n needs to be updated to work with a different directory structure.

@bobbingwide
Copy link
Owner Author

Having updated t10n I was able to re-activate the template part override to demonstrate the loading of localized template parts on the front end.

I can't remember whether or not I managed to achieve loading of localized templates but I've found a note that suggests I didn't bother. It says

We can implement a local solution for the Fizzie theme that doesn't require changes to Gutenberg with the following assumptions.

  • The block-template files only contain non-translatable content

bobbingwide/oik-i18n#7 (comment)

@bobbingwide
Copy link
Owner Author

The current logic for overriding template parts doesn't work for template parts that are created in the Site Editor or Post Editor.
On the front end it displays a message saying that the language file couldn't be found.
The logic doesn't try to locate the post for the template part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant