marhali / easy-i18n

This is a IntelliJ IDE based plugin for internationalization. Supports the most common translation file types.
MIT License
78 stars 24 forks source link

Support for js/ts files (Plain JavaScript objects) #401

Open Jocelyn-AGORO opened 2 months ago

Jocelyn-AGORO commented 2 months ago

When trying the plugin and choosing JSON as file type and using *.ts wilcard, I got the following error : Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $ which I think is due to the plugin trying to load and deserialize the typescript translation files. I think this can be resolve by adding javaScript/Typescript to the supported types and not try to serialize the file content since it will already be plain js objects

Capture d’écran de 2024-05-02 14-07-41

marhali commented 1 month ago

So you are expecting that these js/ts files default export a object?

AC-0308 commented 2 weeks ago

Yes, just like this:

// somefile.ts/somefile.js
export default {
  foo: "this is foo",
}

and more:

module.exports = {
  foo: "this is foo",
}
AC-0308 commented 2 weeks ago

Yes, just like this:

// somefile.ts/somefile.js
export default {
  foo: "this is foo",
}

and more:

module.exports = {
  foo: "this is foo",
}

You may use Node.js cli and loaders in npm(refer: i18n-ally)