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

Support i18n custom blocks for Vue SFC #751

Closed
milespetrov opened this issue Apr 8, 2022 · 8 comments · Fixed by #782 or kingyue737/i18n-ally#1
Closed

Support i18n custom blocks for Vue SFC #751

milespetrov opened this issue Apr 8, 2022 · 8 comments · Fixed by #782 or kingyue737/i18n-ally#1

Comments

@milespetrov
Copy link

What framework do you want to have? Please provide links of its i18n solution/package.
@intlify/vite-plugin-vue-i18n

Please provide some overall screenshots about how the i18n usage would be like
Example

<template>
  <form>
    <label>{{ t('language') }}</label>
    <select v-model="locale">
      <option value="en">en</option>
      <option value="ja">ja</option>
    </select>
  </form>
  <p>{{ t('hello') }}</p>
</template>

<script>
import { useI18n } from 'vue-i18n'

export default {
  name: 'App',
  setup() {
    const { locale, t } = useI18n({
      inheritLocale: true
    })

    return { locale, t }
  }
}
</script>

<i18n>
{
  "en": {
    "language": "Language",
    "hello": "hello, world!"
  },
  "ja": {
    "language": "言語",
    "hello": "こんにちは、世界!"
  }
}
</i18n>

Additional context

@intlify/vue-i18n-loader is already supported, so this shouldn't be too much effort.

@ytx222
Copy link

ytx222 commented Jun 10, 2022

I have the same need

@ytx222
Copy link

ytx222 commented Jun 10, 2022

Saya mengelola berdasarkan cakupan lokal, kompleksitasnya bisa rumit, misalnya, ada beberapa file yang menyediakan terjemahan pada saat yang sama, setiap file memiliki dua bahasa, atau beberapa cakupan digunakan pada saat yang sama

const { t } = useI18n({ fallbackRoot: false, useScope: 'local' });
const { t: globalT } = useI18n({ fallbackRoot: false, useScope: 'global' });

1654832056209

@olemarius
Copy link

I'm facing an issue with the locale files becoming too big in my project, so we're looking into using instead, so if we have HelloWorldA.vue HelloWorldB.vue and HelloWorldC.vue they could all get /locales/WorldGreetings.json

Unfortunately, both this strategy and inline { ...} will not be detected by i18n ally so this feature would be much appreciated

@kingyue737
Copy link
Contributor

Already supported. Just add "vue-sfc" in enabledFrameworks.

"i18n-ally.enabledFrameworks": ["vue-sfc", "vue"]

i18n-Ally doesn't detect @intlify/vite-plugin-vue-i18n and @intlify/unplugin-vue-i18n. I've opened a PR to fix it.

@Eternal-Rise
Copy link

Eternal-Rise commented Oct 21, 2022

@kingyue737 , do we need any extra settings except i18n-ally.enabledFrameworks? Because every time I open my project i18n-Ally asks me to define the locales directory. But we haven't a particular directory when using <i18n> block in SFC. So, if I ignore this option - the extension just doesn't work. Otherways, it says to me "No locale files loaded"

@reslear
Copy link

reslear commented Dec 20, 2022

same

@onurusluca
Copy link

Is this fixed? I can't still get it working with @intlify/unplugin-vue-i18n.

terales added a commit that referenced this issue Aug 27, 2023
* fix: add vite-plugin-vue-i18n in framework detection

fix #751

* Empty commit to trigger CI

---------

Co-authored-by: Alex Terehov <[email protected]>
huacnlee pushed a commit to huacnlee/i18n-ally that referenced this issue Aug 28, 2023
* fix: add vite-plugin-vue-i18n in framework detection

fix lokalise#751

* Empty commit to trigger CI

---------

Co-authored-by: Alex Terehov <[email protected]>
@navishachiku
Copy link

Is there a way to support the source path of vue-sfc?

<i18n src="./Language.json" />

Reference:
https://kazupon.github.io/vue-i18n/guide/sfc.html#multiple-custom-blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
8 participants