Skip to content
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

Localize messages support #252

azu opened this issue Dec 26, 2016 · 6 comments


Copy link

commented Dec 26, 2016

stylelint support reporting custom message that is defined by user.

  "color-hex-case": [ "lower", {
    "message": "Lowercase letters are easier to distinguish from numbers"
  } ],
  "indentation": [ 2, {
    "ignore": ["block"],
    "message": "Please use 2 spaces for indentation. Tabs make The Architect grumpy.",
    "severity": "warning"
  } ]

This feature is needed for textlint.
Because, I know that textlint is used in some web application and software.
These application require "custome message" feature I think.

Can someone has implementation idea?



Primary, We want to support following cases.

  • Localize messages
    • textlint should have Internationalisation(i18n) system
  • Custom messages by textlint application user
    • Application user can modify message
    • For example, an app that use textlint can customize report message.
  • improve message test by textlint-tester
  • (Optional) Lint messages by textlint-tester
    • Lint error message
    • message should be start capitalized?
    • We want to prepare minimal pattern as recommendation
Optional(if it is as possibe)

@azu azu added the Idea label Dec 26, 2016


This comment has been minimized.

Copy link
Member Author

commented Mar 21, 2017

I think that a casual User not needed custome message.
But, i18n/L10n message help user to read error message.

I propose that

  • The user define your local like en-US, ja-JP in .textlintrc
    • If the local is not defined, use os-locale by default.
  • textlint pass the locale information to a rule via context object
  • The rule can localize message by the locale.
    • textlint-rule-helper help the localization.

It is very small start.


This comment has been minimized.

Copy link
Member Author

commented Mar 21, 2017

📝 textlint will provide custom message by custom plugin/settings, maybe

       "rule-a": {
          "message-id": "localized message"
	"rules": {
    	    "rule-a": true

This comment has been minimized.

Copy link
Member Author

commented Jan 21, 2018

markuplint has localize function.

const message = await messages(locale, 'error');

@azu azu changed the title Custom messages support Localize messages support Jul 15, 2018


This comment has been minimized.

Copy link
Member Author

commented Jul 15, 2018

I have thought about it and meta data for rule.

- textlint.meta.json
- rule.js


  "messages": {
     "id-a": "message a {key}",
     "id-b": {
       "ja": "メッセージ B",
       "en": "Message B"


const meta = require("./textlint.meta.json");
export default function(context) {
    const { RuleError, localize, report} = context;
    return {
        [context.Syntax.Str](node) {
            const message = localize(meta.messages["id-a"], { key: "value"});
            report(node, new RuleError(message));
        [context.Syntax.Paragraph](node) {
            const message = localize(meta.messages["id-b"]);
            report(node, new RuleError(message));


dependency flow:

rule.js explicitly depend on textlint.meta.json by design.
It allow to bundle a single file that include textlint.meta.json.
It is fit for browser.

meta file:

textlint.meta.json is separataed file.
It cab be written meta object for the rule.
Maybe, it is useful location for Options Schemas.
External application that include textlint can read textlint.meta.json without executing rule.js.

message format:
ICU formatter is better? depended on Intl.

And, Node.js does not support full-icu by default


Custom messages by textlint application user

application user can modify textlint.meta.json before to lint text by the rule.


This design is depended on location of textlint.meta.json.
Some rule use flat directory.


This comment has been minimized.

Copy link
Member Author

commented Jul 8, 2019

Option Schema is related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.