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
Possibility to translate "message" properties of json configs #7472
Comments
In JSON config, can you try stylelint/docs/user-guide/configure.md Lines 162 to 173 in 38e0606
|
This more immediate request worked for now. Thank you. I didn't find this information before... I believe it remain open other suggestions in this thread. |
Important to say that the variable "%s", as provided by @ybiquitous, doesn't work currently in all rules. This seems to be a Stylelint bug. For example: "color-named", "font-family-name-quotes" and "font-weight-notation" rules. A translated message for these rules, saved in .json file, is correctly being shown in the terminal, except its "%s" variable. |
Closing as a dupe of #6966. Please consider contributing to that issue if you have time so that we can provide the feature for all rules. |
oh i dont understand a lot of code, sorry, i wish i could, you were nice xiexie! |
What is the problem you're trying to solve?
When a custom stylelint config is saved in .js format, we are able to write the message property in 2 ways:
Scenario 1: JS - Hardcoded message with variable
or even:
Scenario 2: JS - translated message with variable
Both scenarios are going to be applied as expected:
And in the terminal, both the variables and translated messages are processed when they are printed.
My doubt is: instead of saving customConfig in .js format, when saving it in .json format, how can I continue to achieve these 2 scenarios?
Attempt 1: Json - Hardcoded message with variable
The variable {unit} is no longer recognized by Stylelint.
Attemp 2: Json - translated message with variable
or
The variable {unit} is no longer recognized by Stylelint, so I can't even try to translate it with an external library like i18next.
What solution would you like to see?
A solution I would like to achieve for the short term is to be able to: convert a custom Stylelint config from the .js format to the .json format, and to maintain the possibility of saving a custom message that contains default variables provided by Stylelint, such as {unit} in the example above.
Better yet, would be if: 1 - Stylelint could provide translations by default, so I don't need to deal with these conversions of file format and inserting a variable in the .json file; .. and if Stylelint doesn't want to include translations by default, then it would still be good if Stylelint could at least provide a helper function to enable us to provide a translated .js or .json file fullfilled with messages in another language, instead of english, and this somehow would be merged with custom configs that exist in the .json format. As a result, when it comes the time to print messages in terminal, these would be shown translated.
The text was updated successfully, but these errors were encountered: