-
Notifications
You must be signed in to change notification settings - Fork 841
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
Add a polyfill for vue-i18n's useI18n()
composable
#6042
Open
absidue
wants to merge
4
commits into
FreeTubeApp:development
Choose a base branch
from
absidue:use-i18n-polyfill
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+184
−11
Conversation
This file contains 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
absidue
requested review from
PikachuEXE,
ChunkyProgrammer,
kommunarr and
MarmadileManteater
October 30, 2024 15:18
github-actions
bot
added
the
PR: waiting for review
For PRs that are complete, tested, and ready for review
label
Oct 30, 2024
PikachuEXE
reviewed
Oct 31, 2024
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.
PikachuEXE
previously approved these changes
Nov 1, 2024
ChunkyProgrammer
previously approved these changes
Nov 1, 2024
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
github-actions
bot
added
PR: merge conflicts / rebase needed
and removed
PR: waiting for review
For PRs that are complete, tested, and ready for review
labels
Nov 2, 2024
efb4f5ff-1298-471a-8973-3d47447115dc
previously approved these changes
Nov 2, 2024
rip didnt see that the conflicts label got applied |
absidue
dismissed stale reviews from efb4f5ff-1298-471a-8973-3d47447115dc, ChunkyProgrammer, and PikachuEXE
via
November 3, 2024 11:28
010f9a8
Conflicts have been resolved. A maintainer will review the pull request shortly. |
absidue
added
the
PR: waiting for review
For PRs that are complete, tested, and ready for review
label
Nov 3, 2024
PikachuEXE
approved these changes
Nov 4, 2024
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.
Add a polyfill for vue-i18n's useI18n() composable
Pull Request Type
Description
This pull request introduces a polyfill for
vue-i18n
9+'suseI18n
composable as well as a custom auto-fixable ESLint rule to enforce the use of the polyfill.Why?
vue-i18n
8, the version ofvue-i18n
that is compatible with Vue 2, doesn't have theuseI18n
composable, so this polyfill allows us to already migrate components that need to use vue-i18n in the JavaScript section (e.g. accessing the current locale to pass toIntl
APIs or using the translate function in computeds like we do for the drop down labels).vue-i18n
9+'suseI18n
composable cannot be used while thevue-i18n
instance is in legacy modelegacy: true
, but we need legacy mode for components that are still using the Options API (unless we migrate every single component to the Composition API before we use Vue 3, which is unlikely to happen)vue-i18n
9 does have anallowComposition
option, however that option comes with some serious limitations (https://vue-i18n.intlify.dev/guide/migration/vue3#limitations) such as requiring the call touseI18n
to be inside thenextTick()
callback which is only fired after the component has already been mounted/rendered and was removed invue-i18n
10 (https://vue-i18n.intlify.dev/guide/migration/breaking10.html#drop-allowcomposition-option). The polyfill in this PR doesn't have those limitations.ft-shaka-video-player.js
file), this provides a drop-in replacement for theuseI18n
function, so once we turn offlegacy
mode, all we need to do is remove the ESLint rule and update the imports to point tovue-i18n
instead.useI18n
function you import or that your editor has imported the wrong one, as the ESLint rule will catch it and can fix the import for you.vue-i18n
ESLint rules work correctly with this polyfill.Screenshots
Testing
Testing the polyfill
Testing the ESLint rule
import { useI18n } from 'vue-i18n'
to a file and check that ESLint detects it and that the fix works (it should change the text after thefrom
part).import { useI18n, createI18n } from 'vue-i18n'
to a file and check that ESLint detects and and that the fix works (it should edit the existing import to remove the useI18n part and create a second import importing theuseI18n
polyfill)Desktop