From 906dad62a892b97e9b16960c9250f41ee20faffa Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 23 Jul 2024 22:51:26 +0300 Subject: [PATCH] dev: Set up i18n-ally --- .vscode/extensions.json | 5 ++++ .vscode/i18n-ally-custom-framework.yml | 34 ++++++++++++++++++++++++++ .vscode/settings.json | 5 +++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/i18n-ally-custom-framework.yml diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..677843835 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "lokalise.i18n-ally" + ] +} \ No newline at end of file diff --git a/.vscode/i18n-ally-custom-framework.yml b/.vscode/i18n-ally-custom-framework.yml new file mode 100644 index 000000000..66b79a69d --- /dev/null +++ b/.vscode/i18n-ally-custom-framework.yml @@ -0,0 +1,34 @@ +# An array of strings which contain Language Ids defined by VS Code +# You can check available language ids here: https://code.visualstudio.com/docs/languages/identifiers +languageIds: + - javascript + - typescript + - javascriptreact + - typescriptreact + +# An array of RegExes to find the key usage. **The key should be captured in the first match group**. +# You should unescape RegEx strings in order to fit in the YAML file +# To help with this, you can use https://www.freeformatter.com/json-escape.html +usageMatchRegex: + # The following example shows how to detect `t("your.i18n.keys")` + # the `{key}` will be placed by a proper keypath matching regex, + # you can ignore it and use your own matching rules as well + - "[^\\w\\d]t\\(['\"`]({key})['\"`]" + +# A RegEx to set a custom scope range. This scope will be used as a prefix when detecting keys +# and works like how the i18next framework identifies the namespace scope from the +# useTranslation() hook. +# You should unescape RegEx strings in order to fit in the YAML file +# To help with this, you can use https://www.freeformatter.com/json-escape.html +scopeRangeRegex: "useTranslation\\(\\s*\\[?\\s*['\"`](.*?)['\"`]" + +# An array of strings containing refactor templates. +# The "$1" will be replaced by the keypath specified. +# Optional: uncomment the following two lines to use + +# refactorTemplates: +# - i18n.get("$1") + + +# If set to true, only enables this custom framework (will disable all built-in frameworks) +monopoly: true \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 1415c74fa..2ab89f510 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,8 @@ "editor.formatOnSave": false, "editor.defaultFormatter": "esbenp.prettier-vscode", "files.eol": "\n", - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "i18n-ally.localesPaths": [ + "./src/public/translations" + ], }