-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Implement i18n's getLocaleByPath
function
#9504
Conversation
🦋 Changeset detectedLatest commit: 7a39ff4 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I painfully generated a changeset, after installing dependencies in a new environment: I chose a "minor" bump, because a behavior changed, while still being a fix to match the v4 documentation. For this new commit, one workflow about the changeset ("Check mergeability / check") failed with HTTP 403 error (see workflow logs). I'll let you investigate why... |
More context for review:For a working example using my implementation, I finished working on the website where I needed it.
Off-topic:From my experience, possible suggestions for future general i18n improvement:
I made clunky functions and used |
From the description this sounds like a bug fix, if so shouldn't this be a Also, given you have some examples that are not working correctly now, can you add tests? |
Did you mean "patch"? You're right, I see patches are for "backward compatible bug fixes".
Sure, looking into it. |
Following the latest commits:
The CI/CD checks for tests are successful. Ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing this!
Changes
This PR gives a new implementation for the
getLocaleByPath
function.It also fixes a parameter name in another
getLocaleByPath
function, one that is exposed to users.According to the Internationalization guide, the following behavior is expected:
For a given configuration:
The function is expected to behave as:
However, the behavior for the current implementation is:
Explaining the current behavior:
path
argument.path
.The new implementation I'm proposing:
path
argument.undefined
if no match was found.Testing
I don't think this function is tested. I did not add tests.
I just implemented the function in a project of mine, configuring
i18n
to match the example I gave in the above section, which is the same as the example in the documentation.Docs
I aimed to match the existing documentation, so no changes are needed.