bundle-tools icon indicating copy to clipboard operation
bundle-tools copied to clipboard

Option `include` with same named locale files should be merged

Open cutsin opened this issue 3 years ago • 10 comments

eg.

My Config

vueI18n({
  include: ['./myProject/submodule/locales/**', './myProject/locales/**']
})

And my locale files could be places here:

├── ./myProject/
│   ├── ./submodule/locales/en.yaml
│   ├── ./locales/en.yaml

Only './myProject/submodule/locales/**' works right now.

cutsin avatar May 26 '21 07:05 cutsin

This is a very needed feature if splitting code (and locales as well) into multiple modules or plugins.

markusand avatar Nov 20 '21 00:11 markusand

I've been digging into the code and found that the plugin is overriding resource paths, so only the last include is taken into account https://github.com/intlify/bundle-tools/blob/c49d4b79db392318915b726efa9795f91f2e9390/packages/vite-plugin-vue-i18n/src/index.ts#L170

Use instead

resourcePaths = [...resourcePaths, ...(await fg(inc))] ;

This doesn't fix the issue as the language is overriden after this array of language definitions, but I don't understand the code so good to be able to do a pull request https://github.com/intlify/bundle-tools/blob/c49d4b79db392318915b726efa9795f91f2e9390/packages/vite-plugin-vue-i18n/src/index.ts#L343

markusand avatar Nov 20 '21 10:11 markusand

This is a very needed feature if splitting code (and locales as well) into multiple modules or plugins.

It would be really nice indeed to have this working.

Frenkz avatar Dec 07 '21 17:12 Frenkz

i need also code splitting feature, i dont want to use i18n block, and i dont want to have huge files per language splitting and merging in folder structure is absolutely needed feature

volarname avatar Feb 19 '22 20:02 volarname

This is a much needed feature for us. Is there a workaround for the meantime?

realityfilter avatar Feb 22 '22 14:02 realityfilter

Similar use-case. I'm trying to find a way to accomplish the folder structure below and use the folders as language key so messages can understand it. I thought about linking everything together in a src/i18n/index.ts but that is not supported either.

/src/i18n/
│   index.ts
│  
│
└───locales
    │
    ├───en-GB
    │   │   global.json
    │   │
    │   ├───components
    │   │       Example.json
    │   
    └───nl-NL
        │   global.json
        │
        ├───components
        │        Example.json

Then something like t('Example.key') or t('global.key') should be available.

I'm currently unable to use this plugin because this is a must the project I work in.

Vissie2 avatar Feb 24 '22 11:02 Vissie2

anything that will provide possobility to split code and dont use translations directly in components is welcomed, at least this: also the warning about local and global scope is very annoying

────locales
    │
    ├───en
    │   │   common.yaml
    │   │   component1.yaml
    │   │   component2.yaml
    │   
    ├───fr
    │   │   common.yaml
    │   │   component1.yaml
    │   │   component2.yaml

volarname avatar Feb 24 '22 11:02 volarname

any comment from creators? any ETA on this?

volarname avatar Mar 10 '22 08:03 volarname