Make WordPress Core

Opened 13 months ago

Last modified 12 months ago

#60234 new enhancement

Script Modules API: Add a translations API

Reported by: luisherranz's profile luisherranz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Script Loader Keywords:
Focuses: javascript Cc:

Description

Now that WordPress is going to support native ES modules through the new Modules API, we should start discussing possible translation APIs to support internationalization/localization, similar to what wp_set_script_translations provides for the Scripts API.

Some of the initial considerations are:

  • It should support the dynamic loading of translations when used in conjunction with dynamic imports (import()) to avoid downloading all the translations on page load.
  • Ideally, it should download the translations required in the initial page load in parallel to avoid waterfalls on page load.
  • Ideally, it should rely only on available PHP and JavaScript APIs, and not require any specific tooling.
  • Ideally, the APIs should be as transparent as possible to the developers.

Please share your opinions and ideas. Let's use this ticket for discussion.

Change History (2)

#1 @luisherranz
13 months ago

  • Summary changed from Modules API: Add a translations API to Script Modules API: Add a translations API

#2 @jonsurrell
12 months ago

This is related to and may depend on #60647 which would make wp-i18n functionality available to script modules.

Note: See TracTickets for help on using tickets.