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

feat: [KHCP_6176] Expose i18n Translation component for import without Vue plugin #150

Merged
merged 8 commits into from
Feb 16, 2023

Conversation

ValeryG
Copy link
Collaborator

@ValeryG ValeryG commented Feb 16, 2023

Summary

Now i18n-t can be used can be used from component libraries without it being registered via plugin on application level.

packages/core/i18n/README.md Outdated Show resolved Hide resolved
packages/core/i18n/README.md Outdated Show resolved Hide resolved
packages/core/i18n/src/Translation.ts Outdated Show resolved Hide resolved
ValeryG and others added 2 commits February 16, 2023 08:04
Co-authored-by: Adam DeHaven <2229946+adamdehaven@users.noreply.github.com>
packages/core/i18n/sandbox/App.vue Outdated Show resolved Hide resolved
Comment on lines +8 to +11
i18n: {
type: Object as PropType<IntlShapeEx>,
default: null,
},
Copy link
Member

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.

Copy link
Collaborator Author

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>

Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure. documented...

Copy link
Member

@adamdehaven adamdehaven left a comment

Choose a reason for hiding this comment

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

lgtm

@ValeryG ValeryG merged commit 14d6a99 into main Feb 16, 2023
@ValeryG ValeryG deleted the feat/KHCP-6176-i118n-component branch February 16, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants