i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Implement composition API

Open rchl opened this issue 4 years ago • 6 comments

Is your feature request related to a problem? Please describe.

Add a native composition API for use with Vue 3.

Some more info at https://dev.to/alvarosaburido/how-to-migrate-your-library-from-vue2-to-vue3-1h81

rchl avatar Dec 07 '20 08:12 rchl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 07 '21 18:02 stale[bot]

Hola guys, any news on this? Or any work around for the short term?

What's the best way to access methods such as localePath inside the setup method currently?

philipdanielhayton avatar Apr 14 '21 13:04 philipdanielhayton

See https://github.com/nuxt-community/composition-api/issues/425#issuecomment-813102698

rchl avatar Apr 14 '21 13:04 rchl

@rchl any ideas on how to get a translated string inside setup() (when using an <i18n> custom block)? Everything comes back as a raw translation path... totally lost on this. Anything I am doing incorrectly in the below example? I am using Nuxt 2 with Composition API.

<i18n>
{
  "en": {
    "exampleString": "Test"
  }
}
</i18n>

...

setup() {
  const { i18n } = useContext();
  
  console.log(i18n.t("exampleString"));
}

Is this related to https://github.com/nuxt-community/i18n-module/pull/1333? May I ask why this PR is still a draft?

UPDATE I made a Nuxt composable by copying the useI18n() function from the https://github.com/nuxt-community/i18n-module/pull/1333. Works perfectly as a workaround ;)

DamianGlowala avatar Dec 13 '21 14:12 DamianGlowala

On nuxt 2 bridge:

<script setup lang="ts">

const { $i18n } = useNuxtApp()
$i18n.t('key')

</script>

thisismydesign avatar Oct 14 '22 12:10 thisismydesign

@thisismydesign is this suppose to work ?

MatthD avatar Oct 18 '22 09:10 MatthD