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

isLangRightToLeft function not using language config setting #10259

Merged
merged 3 commits into from May 19, 2023

Conversation

corwintines
Copy link
Member

Description

  • Fixes the isLangRightToLeft function to use a languages config for lang direction instead of being hardcoded values for langauges.

Related Issue

Fixes #10258

@github-actions github-actions bot added the needs review 👀 Review is needed for this issue or pull request label May 19, 2023
@gatsby-cloud
Copy link

gatsby-cloud bot commented May 19, 2023

✅ ethereum-org-website-dev deploy preview ready

Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corwintines Pretty sure our build error is related to using the hrefLang instead of the code property... in the case of Filipino we'd be looking for fil but this doesn't exist and would result in the array being empty, and [0] wouldn't work.

src/utils/translations.ts Outdated Show resolved Hide resolved
return lang === "ar" || lang === "fa"
const langConfig = i18nConfigs.filter(
(language) => language.hrefLang === lang
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also want to guard (or throw an error) against the case where our filtered array is empty (no matches)

Maybe:

if (!langConfig.length) throw new Error("Language code not found")

or

if (!langConfig.length) return "rtl"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ill do the first one with throwing an error. Think this would make it easier to debug as this would be an issue. Thanks for the suggestion

corwintines and others added 2 commits May 18, 2023 20:51
Co-authored-by: Paul Wackerow <54227730+wackerow@users.noreply.github.com>
@wackerow wackerow merged commit 113b444 into dev May 19, 2023
3 checks passed
@wackerow wackerow deleted the isLangRightToLeftFix branch May 19, 2023 03:36
@corwintines corwintines mentioned this pull request May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review 👀 Review is needed for this issue or pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isLangRightToLeft function not using language config setting
2 participants