kazupon / vue-i18n

:globe_with_meridians: Internationalization plugin for Vue.js

Home Page:https://kazupon.github.io/vue-i18n/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem in build env when trying to use json in Javascript

NathanAP opened this issue · comments

Reporting a bug?

Hi! I'm not sure if this is the right way to talk about my situation. I'm really sorry if it isn't.

I have a file which contains my locale data, one of them contains something like this:

{ 
   "translateList": {
      "type": {
         "title": "Tipo",
         "position": 2,
         "attribute": "types"
      }
   }
}

I'm trying to use vue-i18n programatically in my app, directly in Javascript. As you can see in the first image, when I run in dev, I have that source data which contains the key that I need, so if I do attribute.source, I get types, awesome.

Screenshot_2

The problem is that when I use npm run build, that attribute changes to the second image and I no longer have the source data, so my attribute.source is now undefined as you can see in the second image here:

Screenshot_3

How can I get that "types" value that is specified in "attribute" key?

edit: after some testings I noticed that accessing position always bring the value 2 correctly its seems that strings has different behavior?

Expected behavior

I feel that .source should keep sending us the same data in build and dev.

Reproduction

I have no data ):

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-9700KF CPU @ 3.60GHz
    Memory: 6.83 GB / 15.92 GB
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.13.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 105.0.5195.102
    Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.42)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @intlify/vite-plugin-vue-i18n: ^6.0.1 => 6.0.1
    @vitejs/plugin-basic-ssl: ^0.1.2 => 0.1.2
    @vitejs/plugin-vue: ^3.0.3 => 3.0.3
    vite: ^3.0.5 => 3.0.9
    vite-plugin-vuetify: ^1.0.0-alpha.12 => 1.0.0-alpha.14
    vue: ^3.2.37 => 3.2.37
    vue-advanced-cropper: ^2.8.3 => 2.8.3
    vue-axios: ^3.4.1 => 3.4.1
    vue-cli-plugin-vuetify: ~2.5.4 => 2.5.4
    vue-i18n: ^9.2.2 => 9.2.2
    vue-router: ^4.1.4 => 4.1.4
    vuetify: ^3.0.0-beta.0 => 3.0.0-beta.9
    vuetify-loader: ^2.0.0-alpha.0 => 2.0.0-alpha.9

Screenshot

No response

Additional context

No response

Validations