-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: [KHCP_6176] Expose i18n Translation component for import without Vue plugin #150
Conversation
Co-authored-by: Adam DeHaven <2229946+adamdehaven@users.noreply.github.com>
i18n: { | ||
type: Object as PropType<IntlShapeEx>, | ||
default: null, | ||
}, |
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.
question: now that I'm looking at this logic, we always pass in the i18n
object as a parameter as shown here:
const i18nT = i18nTComponent(i18nLocal)
So it looks like we never actually pass in the i18n
prop in any of our documented use-cases because it has to be passed into the function when registered in the component.
I think this makes sense, because if you used the prop, you would have to pass in the i18n
object in your <template>
usage every single time, which would not be ideal.
So I think we can actually remove the prop
, and then in the function call above, expect the i18n: IntlShapeEx
to be a required parameter, meaning we also don't need to fallback to the prop below.
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.
in case of you do old defaultComponent
way you might need to use i18n as prop
<template>
<i18n-t :i18n="i18n"/>
</template>
<script lang="ts">
import {i18nTcomponent, createI18n} from ...
import english from ...
defineComponent({
components: {i18nTcomponent()},
setup() {
return {
i18n: createI18n(English)
}
})
</script>
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.
So then should we document this usage example as well?
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.
sure. documented...
Co-authored-by: Adam DeHaven <2229946+adamdehaven@users.noreply.github.com>
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.
lgtm
Summary
Now
i18n-t
can be used can be used from component libraries without it being registered via plugin on application level.