vuejs / create-vue

🛠️ The recommended way to start a Vite-powered Vue project
Other
3.68k stars 421 forks source link

i18n vue plugin option ? #545

Open ArcadeCode opened 1 month ago

ArcadeCode commented 1 month ago

Please describe

I use vue I18n who is really helpful for Internationalization but he need some configuration and I will really appreciate if I can have an option in create-vue for this, but I checked the code and I'm not qualified to understand it.

Additional context

To make a fast configuration the vue-i18n doc propose to config all in the main.ts but it's more clear to make a local(s) folder with all traductions and import it in the main.ts or use a i18n folder: image

Anyone think it will be good idea ?

Procrustes5 commented 1 month ago

I am developing in Japanese and Korean, totally agree with you.

When the project grows to a certain extent, I have often thought that it would be nice if the i18n was set up at the stage of making the project.

I think it's also good for the configuration of creating folders on i18n.

Procrustes5 commented 1 month ago

https://github.com/vuejs/create-vue/pull/548 Made a pull request based on your issue. If you have any opinions, please give it to me.

messenjer commented 1 month ago

In general, I put my i18n configuration into a separate folder: plugins/i18n.ts

I keep the translation files in the locales folder: src/locales/en.json.

This separation makes it easy to specify the folder containing the translations when using various translation tools:

{
    "i18n-ally.localesPaths": [
        "src/locales"
    ]
}
export default defineConfig({
  plugins: [
    VueI18nPlugin({
      include: [path.resolve(__dirname, './src/locales/**')],
    }),
  ],
})

I find this approach to be more modular.

ArcadeCode commented 1 month ago

Yes it will be more modular in this way, but in this idea why don't moving router.ts in the plugins folder ?

messenjer commented 3 weeks ago

In the previous vue installer vue-cli-i18n https://github.com/intlify/vue-cli-plugin-i18n

The file was located here :

src/i18n.(js|ts)

And the default localeDir was src/locales

it should be another solution.

ArcadeCode commented 3 weeks ago

Sounds good to me if we take the example from the i18n vue-cli plugin.