Open Matiaseid opened 4 years ago
Indeed, translations are only in json and in yaml files for now. Could you please give some examples of how you use translations in js files?
I believe I'm incurring in the same issue: Cannot resolve symbol 'profile.displayName'
.
With the Vue i18n plugin, one must declare an i18n
folder in the app/src
that has an index.js
.
My structure is like this:
app/src
|– i18n
|- de-ch
|- en-uk
| |– profile.js
| |- index.js
|- index.js
app/src/i18n/index.js
:
import enUK from './en-uk'
import deCH from './de-ch'
export default {
'en-uk': enUK,
'de-ch': deCH,
}
app/src/i18n/en-uk/index.js
:
import profile from './profile.js'
export default {
cancel: 'Cancel',
required: 'Required',
profile,
}
And app/src/i18n/en-uk/profile.js
also exports an object.
Glad to contribute, if someone can assist me getting started (I've never developed an IntelliJ plugin).
Hi, Carlos!
Thanks for your interest to the project! I've started an investigation of this problem and found that for general case, mentioned in the first post it is kinda tricky to implement the desired behaviour, but it is possible. Probably, some hint from user will be required - to mark somehow or provide a path to file, containing i18next initialization (call to init function). For the case of vue-i18n if I get you right, it is much easier to implement this support, since the location of js files, containing translations is defined, it is folder i18n.
Contributions are welcome, so if you want to try to implement this feature, start investigating at LocalizationFileSearch. From my experience it is very good practice to debug such features on test input, so take a look at project's tests, particularly CodeHighlightingTest -> testVueUnresolvedKey.
If you have any questions don't hesitate to ask me!
Regards, Evgeniy
Hi, @carloschida! I'm investigating how to implement js configured translation feature and found this example: https://github.com/kazupon/vue-i18n/tree/dev/examples/formatting/custom. In this project configuration differs from one described by you. There created object VueI18n holding all translation references and this object then passed to Vue constructor. I've copied project from link above to https://github.com/nyavro/i18nPlugin/tree/master/examples/vue-i18n-js-config-simple and now I'm trying to implement support for this kind of configuration. Could you please create very simple working project similiar to vue-i18n-js-config-simple, configured the way you described in examples folder? I would greately appreciate that! This would be starting point to development of this js-configuration feature and eventually implement if for all possible js-configurations, not only vue-i18n.
Regards, Evgeniy
+1
I'm using React instead of Vue, but .js (or .ts) file support as translation sources would be nice. For me, they are just in the same format as the json files, but instead of JSON, it is a plain Javascript object containing the translations exported with module.exports. Js files are nicer as you can have comments and easily do overrides/calculated translations based on environment or other stuff.
+1👍 I don't know any Kotlin so I can't help implementing it, but I would love to have it :) I have exactly the same structure as Carloschida.
In the readme I only see examples of translations based on .json files. For my project I need to use .js files that export an object.
Maybe there already is support for this and I just configured it wrongly?
Thanks for your work.