-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing recommended config with valid translations? #7
Comments
Hi @lmenus 😄, we support ICU Message Syntax by default. Nice guide on it: https://formatjs.io/guides/message-syntax/. (React-Intl uses ICU Message Syntax) Which message syntax are you using? looks like Another way to get this working/test around is by writing a customer message syntax validator as shown in this example: https://github.com/godaddy/eslint-plugin-i18n-json/tree/master/examples/custom-message-syntax Hope this helps! |
Hi @mayank23, yes and yes, those are good guesses! I only created this issue because it didn't feel right to use a |
Planning on adding support for i18n-next very soon 😄 . As a temporary measure, you could override the recommended settings to disable the syntax rule or use the built-in The Example config with builtin // .eslintrc.json
"extends": [
"plugin:i18n-json/recommended"
],
"rules": {
"i18n-json/valid-message-syntax": [2,{
"syntax": "non-empty-string"
}]
} Example config with the syntax rule disabled . // .eslintrc.json
"extends": [
"plugin:i18n-json/recommended"
],
"rules": {
"i18n-json/valid-message-syntax": 0
} |
Thank you! Are you going to support objects (including arrays) as keys in the |
I have to look more closely at i18n-next, but yes nested objects will be supported definitely. Thanks! |
Sure. React/JSX syntax supports arrays as arguments and I found it useful to add
Then in React this would get rendered like so. render() {
let lines = [];
translationArray.forEach((line, index) => {
lines = [
...lines,
line,
<br key={index} />,
];
});
return lines;
} Result <p>
line1 <br />
line2 <br />
</p> This is used specifically for plain text that just needs to be spread across multiple lines. If we were to add more rich text editing features, this solution wouldn't be very useful. |
Awesome, thanks for the example 😉 |
Maybe we can use https://github.com/i18next/i18next-translation-parser to add support for i18next format, let me know if that works I can give it a try |
Hi @silentsakky :) , does that library tell us if the syntax is incorrect? I did a quick scan and couldn't find any error handling code in that library |
@mayank23 I wrote a quick message validator using |
@mayank23 to answer your question though (oops!), I never saw |
Hello,
I have just found out about this plugin and decided to test it on a working project. For the sake of example, I will simplify my translation files down to the following file
locales/translation.json
.Then in
.eslintrc.json
I added this line to theextends
array.And added this script to
package.json
.Let's execute
yarn lint-i18n
now...How do I make this test pass? Whenever this translation is used, it gets injected the
limit
variable. Thanks for any advice!The text was updated successfully, but these errors were encountered: