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

i18n: the isRTL flag should be provided by the current locale data #19212

Closed
jsnajdr opened this issue Dec 18, 2019 · 2 comments
Closed

i18n: the isRTL flag should be provided by the current locale data #19212

jsnajdr opened this issue Dec 18, 2019 · 2 comments
Assignees
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts [Package] i18n /packages/i18n

Comments

@jsnajdr
Copy link
Member

jsnajdr commented Dec 18, 2019

Currently, when Gutenberg code needs to know if the current text direction is LTR or RTL, it gets it from various sources:

  • the Block Editor has isRTL value in its settings
  • components query the DOM: document.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 is rtl, then we're dealing with a RTL language. See the usage of this translation string in Core PHP WP_Locale class

@wordpress/i18n should export a new function that returns authoritative value of the RTL flag:

import { isRTL } from `@wordpress/i18n`;

const popoverAlignment = isRTL() : 'left' : 'right';
@jsnajdr jsnajdr added Internationalization (i18n) Issues or PRs related to internationalization efforts [Package] i18n /packages/i18n labels Dec 18, 2019
@sirreal sirreal mentioned this issue Feb 18, 2020
6 tasks
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 18, 2020
@sirreal
Copy link
Member

sirreal commented Feb 18, 2020

I've opened #20298 to implement isRTL.

@sirreal sirreal removed their assignment Feb 18, 2020
@sirreal
Copy link
Member

sirreal commented Jan 20, 2021

With #20298 and #27838 I believe this is complete.

@sirreal sirreal closed this as completed Jan 20, 2021
@sirreal sirreal removed the [Status] In Progress Tracking issues with work in progress label Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts [Package] i18n /packages/i18n
Projects
None yet
Development

No branches or pull requests

3 participants