Skip to content

Commit

Permalink
docs(config): document prettierIgnore and eslint disable options
Browse files Browse the repository at this point in the history
  • Loading branch information
fdrault committed Aug 5, 2024
1 parent 51eaa67 commit b5ed116
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,42 @@ translate("goodbye"); // OK
```json
{
"input": {
"format": "flatten",
"path": "./i18n/en.json"
"format": "nested",
"path": "./input/default.json"
},
"output": {
"path": "./i18n/translations.d.ts"
"path": "./output/default.d.ts"
},
"rules": [
{
"//": "Add pluralization placeholders",
"condition": { "keyEndsWith": ["zero", "one", "other"] },
"transformer": {
"addPlaceholder": { "name": "count", "type": ["number", "string"] },
"removeLastPart": true
}
},
{
"//": "Add interpolation values for matched placeholders",
"condition": { "placeholderPattern": { "prefix": "{{", "suffix": "}}" } },
"transformer": {
"addMatchedPlaceholder": { "type": ["string", "number"] }
}
}
],
"extra": {
"prettierIgnore": true,
"eslintDisablePrettier": false
}
}
```

- input `format` support JSON translations file with
- `flatten` keys like `home.header.greeting`
- nested scoped dictionnaries: `{ home: { header: { greeting: "hello" } } }`
- extra de-opt generated files from prettier or eslint prettier rule to comply with specific configurations.
- `prettierIgnore` add `// prettier-ignore` in generated file.
- `eslintDisablePrettier` add `/* eslint-disable prettier/prettier */` in generated file.

### Recommended Toolbox

Expand All @@ -103,10 +127,7 @@ type MyCustomI18n = Omit<I18n, "t"> & {
* Same as `t` without any type checking.
* Should be used only when the translation key cannot be statically inferred.
*/
unsafeTranslate: (
key: string,
interpolations?: Record<string, unknown>
) => string;
unsafeTranslate: (key: string, interpolations?: Record<string, unknown>) => string;
};

class MyInternationalization extends I18n {
Expand Down

0 comments on commit b5ed116

Please sign in to comment.