i18n: the isRTL flag should be provided by the current locale data #19212
Labels
Internationalization (i18n)
Issues or PRs related to internationalization efforts
[Package] i18n
/packages/i18n
Currently, when Gutenberg code needs to know if the current text direction is LTR or RTL, it gets it from various sources:
isRTL
value in its settingsdocument.documentElement.dir === 'rtl'
But there is one place that could and should be the source of truth for everyone -- the
@wordpress/i18n
library and its current locale.Every WordPress locale has a special translation string called
_x( 'ltr', 'text direction' )
. If the translation isrtl
, then we're dealing with a RTL language. See the usage of this translation string in Core PHPWP_Locale
class@wordpress/i18n
should export a new function that returns authoritative value of the RTL flag:The text was updated successfully, but these errors were encountered: