[wp-trac] [WordPress Trac] #54858: i18n: Missing locale data if part of the translation are empty

WordPress Trac noreply at wordpress.org
Wed Jan 19 11:16:28 UTC 2022


#54858: i18n: Missing locale data if part of the translation are empty
--------------------------+-----------------------------
 Reporter:  arthur791004  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  I18N          |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 As https://github.com/WordPress/gutenberg/pull/37686 and
 https://github.com/WordPress/gutenberg/pull/37704 mentioned,
 `print_translations` function will register an empty locale data object to
 ensure the domain still exists even if there is no translation for the
 specific domain. However, if we call `wp.i18n.setLocaleData` with the
 empty locale data, the `lang` property in the domain configuration will be
 overridden and gone. See
 [https://github.com/WordPress/WordPress/blob/48aa21e9d9894696de4102783f17e81441c8e134
 /wp-includes/class.wp-scripts.php#L610].

 I propose a change to add a new method `wp.i18n.addLocaleData` and the
 domain configuration will be merged rather than overridden so that the
 `lang` property can be kept even if we call that function with an empty
 locale.

 Thus, we should also update the `print_translations` function to use
 `wp.i18n.addLocaleData`.

 If we have any concerns about the breaking change, I'm not sure is there a
 better way to use `wp.i18n.addLocaleData`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54858>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list