Merged
Conversation
Contributor
Author
|
@greptileai rereview plz |
Contributor
Author
|
@greptileai plz re-review |
Contributor
Author
|
@greptileai plz re-review |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Contributor
Author
|
@greptileai plz review |
packages/core/src/locales/__tests__/getLocaleDirection.node.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
archie-mckenzie
approved these changes
Mar 4, 2026
Merged
ErnestM1234
pushed a commit
that referenced
this pull request
Mar 4, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## gtx-cli@2.6.29 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 ## @generaltranslation/compiler@1.1.22 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 ## generaltranslation@8.1.13 ### Patch Changes - [#1061](#1061) [`21b3304`](21b3304) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: language direction browser compatibility ## gt-i18n@0.4.1 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 - @generaltranslation/supported-locales@2.0.46 ## locadex@1.0.107 ### Patch Changes - Updated dependencies \[]: - gtx-cli@2.6.29 ## gt-next@6.13.2 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 - @generaltranslation/compiler@1.1.22 - gt-i18n@0.4.1 - gt-react@10.11.1 - @generaltranslation/supported-locales@2.0.46 ## @generaltranslation/gt-next-lint@11.0.2 ### Patch Changes - Updated dependencies \[]: - gt-next@6.13.2 ## gt-node@0.2.7 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 - gt-i18n@0.4.1 ## gt-react@10.11.1 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 - @generaltranslation/react-core@1.5.1 - @generaltranslation/supported-locales@2.0.46 ## @generaltranslation/react-core@1.5.1 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 - gt-i18n@0.4.1 - @generaltranslation/supported-locales@2.0.46 ## gt-sanity@1.1.20 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 ## @generaltranslation/supported-locales@2.0.46 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 ## gt-tanstack-start@0.1.8 ### Patch Changes - Updated dependencies \[[`21b3304`](21b3304)]: - generaltranslation@8.1.13 - gt-i18n@0.4.1 - gt-react@10.11.1 - @generaltranslation/react-core@1.5.1 ## gt-next-middleware-e2e@0.1.2 ### Patch Changes - Updated dependencies \[]: - gt-next@6.13.2 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This issue was first pointed out in https://discord.com/channels/1337588892672725085/1477045064327758039 by user ibr.lol95 who noticed that
getLocaleDirection("ar-EG")was incorrectly outputting "ltr". We narrowed this behavior down to browser environments only. This is caused by an older version of theIntlin browser environments. We had two options here which is to fix via polyfill or by manually checking forrtllanguages. We decided to go with the latter to avoid potential side effects.Greptile Summary
This PR fixes a real browser-environment bug where
getLocaleDirection("ar-EG")(and similar region-tagged Arabic locales) incorrectly returned"ltr"because older browserIntlimplementations do not expose thetextInfoproperty onIntl.Locale. The fix introduces a three-tier fallback strategy: prefertextInfowhen available, then resolve via the maximized script code (from_getLocaleProperties), and finally fall back to a hardcodedRTL_LANGUAGESset. New test files correctly simulate both a browser-without-textInfoenvironment and a Node.js environment.ar-EGwithouttextInfo,_getLocalePropertiescallsmaximize()to discover theArabscript, whichisRtlScriptcorrectly identifies as RTL.RTL_SCRIPTSis slightly incomplete:yezi(Yezidi — an actively-used living script) is absent, meaning locales with an explicit Yezidi script tag would fall through to a language-based check. See inline comment.extractDirectionWithTextInfo(line 85) can be removed without changing behavior._getLocalePropertiesas the fallback vehicle is a heavyweight call (createsDisplayNamesobjects, callsmaximize()andminimize()) just to obtainscriptCodeandlanguageCode. This is only triggered whentextInfois unavailable so the practical performance impact is low, but a lighter helper would be cleaner long-term.browserLocale) in the Node-environment test file — minor readability issue.Confidence Score: 4/5
ar-EGregression in browsers withouttextInfo. The heuristic sets are reasonable for practical locales. No debug logging remains in production code. The small issues found (missingyeziscript, redundant truthy check, misleading variable name) are all style-level and do not break any tested behavior.packages/core/src/locales/getLocaleDirection.ts— specifically the completeness ofRTL_SCRIPTS.Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["_getLocaleDirection(code)"] --> B["intlCache.get('Locale', code)"] B -->|throws| C["silent catch"] B -->|success| D["extractDirectionWithTextInfo(locale)"] D -->|"textInfo present & valid ('ltr'|'rtl')"| E["return textInfo.direction"] D -->|"textInfo absent or invalid"| F["fall through"] C --> F F --> G["_getLocaleProperties(code)"] G --> H{scriptCode?} H -->|non-empty| I["isRtlScript(scriptCode)"] I -->|true| J["return 'rtl'"] I -->|false| K["return 'ltr'"] H -->|empty| L{languageCode?} L -->|non-empty| M["isRtlLanguage(languageCode)"] M -->|true| N["return 'rtl'"] M -->|false| O["return 'ltr'"] L -->|empty| P["return 'ltr'"]Last reviewed commit: 9aa338c