godaddy / eslint-plugin-i18n-json

Fully extendable eslint plugin for JSON i18n translation files.
https://godaddy.github.io/2018/04/02/introducing-eslint-plugin-i18n-json/
MIT License
182 stars 25 forks source link

Comment validation support #22

Closed redonkulus closed 4 years ago

redonkulus commented 5 years ago

In our translation files, we require translator notes to add proper context for translators. Example:

{
  //@note: Button text to buy an item
  “BUY_ME”: “Buy me”
}

I’d like the comment to be required for each string. Is this something that this plugin could handle? Or is there a way to provide this functionality be extending this plugin?

mayank23 commented 5 years ago

Hi 😄 ,

Couple options at the moment I can think of:

1) use objects for the translations keys and include a property for description and translation value like so:

{
  "BUY_ME": {
    "description": "Button text to buy an item",
    "value": "Buy me"
  }
}

If you can do this, then you can use the identical-keys rule to ensure each file has the same key structure (including description) - all files have to match the key structure to some reference translation file. https://github.com/godaddy/eslint-plugin-i18n-json/#i18n-jsonidentical-keys

2) have a separate module preprocess the translation files then send them to eslint

Would any of these help?

mayank23 commented 4 years ago

Closing due to no response.