From 9411b6380b4699b21f7819ecfda6d8d29a100f0c Mon Sep 17 00:00:00 2001 From: Nir Tamir Date: Sun, 7 Jul 2024 23:27:34 +0300 Subject: [PATCH] i18n --- src/configs/i18n.ts | 99 ++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/src/configs/i18n.ts b/src/configs/i18n.ts index f0197d6d50..dd8833508e 100644 --- a/src/configs/i18n.ts +++ b/src/configs/i18n.ts @@ -14,60 +14,57 @@ export async function i18n(): Promise> { ]); return [ - { - name: "nirtamir2/i18n", - ...fixupConfigRules( - compat.config({ - extends: [ - "plugin:i18n-prefix/recommended", - "plugin:i18next/recommended", + ...fixupConfigRules( + compat.config({ + extends: [ + "plugin:i18n-prefix/recommended", + "plugin:i18next/recommended", + ], + plugins: ["@naturacosmeticos/i18n-checker"], + rules: { + /** + * This will error if `t` function called with a translation key + * that does not exist in translation files + */ + "@naturacosmeticos/i18n-checker/path-in-locales": [ + "error", + { + localesPath: "locales/", + messagesBasePath: "translations", + translationFunctionName: "t", + }, ], - plugins: ["@naturacosmeticos/i18n-checker"], - rules: { - /** - * This will error if `t` function called with a translation key - * that does not exist in translation files - */ - "@naturacosmeticos/i18n-checker/path-in-locales": [ - "error", - { - localesPath: "locales/", - messagesBasePath: "translations", - translationFunctionName: "t", - }, - ], - /** - * i18n translation should be the same as component name - */ - "i18n-prefix/i18n-prefix": [ - "error", - { - translationFunctionName: "t", - delimiter: ".", - ignorePrefixes: ["enum"], - }, - ], - }, - overrides: [ + /** + * i18n translation should be the same as component name + */ + "i18n-prefix/i18n-prefix": [ + "error", { - files: ["**/locales/**/*.json"], - extends: ["plugin:i18n-json/recommended"], - rules: { - "i18n-json/valid-message-syntax": [ - "error", - { - /** - * This allows using the i18next format with {param} syntax - * @see https://github.com/godaddy/eslint-plugin-i18n-json/issues/40#issuecomment-842474651 - */ - syntax: path.resolve("./i18next-syntax-validator.mjs"), - }, - ], - }, + translationFunctionName: "t", + delimiter: ".", + ignorePrefixes: ["enum"], }, ], - }), - ), - }, + }, + overrides: [ + { + files: ["**/locales/**/*.json"], + extends: ["plugin:i18n-json/recommended"], + rules: { + "i18n-json/valid-message-syntax": [ + "error", + { + /** + * This allows using the i18next format with {param} syntax + * @see https://github.com/godaddy/eslint-plugin-i18n-json/issues/40#issuecomment-842474651 + */ + syntax: path.resolve("./i18next-syntax-validator.mjs"), + }, + ], + }, + }, + ], + }), + ), ]; }