Skip to content

i18n: Merge PHP and JS strings in POT generation #5169

@aduth

Description

@aduth

Related discussion: https://wordpress.slack.com/archives/C5UNMSU4R/p1519137264000547

The current npm run gettext-strings script will generate a languages/gutenberg.pot file using a custom Babel plugin, but only includes strings discovered in the JavaScript source, not those in PHP. The PHP strings can be generated by i18n tools for PHP.

Furthermore, it appears that the automatic plugin integration for Gutenberg + GlotPress will ignore the custom generated POT file and scan PHP files for strings, thereby ignoring the JavaScript strings altogether.

There are a few options to proceed here:

  • We can generate a file which includes the JavaScript strings written as PHP equivalent function calls, which are detected by plugin integration automatically. This is a bit of a hack, but one which has served both Yoast and WordPress.com Calypso.
  • We can work to improve GlotPress interoperability with projects with JavaScript localization, and include in our build step both JS and PHP string extraction with merge

In either case, we also want to ensure that, if possible, we only load strings into the browser which are relevant to JavaScript usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Internationalization (i18n)Issues or PRs related to internationalization efforts[Type] TaskIssues or PRs that have been broken down into an individual action to take

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions