Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Typecheck & lint the i18next-parser config
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Oct 19, 2023
1 parent 128964d commit 5f7bc2a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 22 deletions.
1 change: 0 additions & 1 deletion frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
"**/coverage/**",
"!.storybook",
"*/gql/*.ts",
"i18next-parser.config.js",
],
overrides: [
// General rules for JS/TS files
Expand Down
18 changes: 0 additions & 18 deletions frontend/i18next-parser.config.js

This file was deleted.

36 changes: 36 additions & 0 deletions frontend/i18next-parser.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2023 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import type { UserConfig } from "i18next-parser";

const config: UserConfig = {
keySeparator: ".",
pluralSeparator: ":",
defaultNamespace: "frontend",
lexers: {
ts: [
{
lexer: "JavascriptLexer",
functions: ["t", "translatedError"],
namespaceFunctions: ["useTranslation", "withTranslation"],
},
],
},
locales: ["en"],
output: "public/locales/$LOCALE.json",
input: ["src/**/*.{ts,tsx}"],
sort: true,
};

export default config;

Check warning on line 36 in frontend/i18next-parser.config.ts

View check run for this annotation

Codecov / codecov/patch

frontend/i18next-parser.config.ts#L1-L36

Added lines #L1 - L36 were not covered by tests
4 changes: 2 additions & 2 deletions frontend/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import * as i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import I18NextHttpBackend from "i18next-http-backend";
import I18NextHttpBackend, { HttpBackendOptions } from "i18next-http-backend";
import { initReactI18next } from "react-i18next";

i18n
Expand All @@ -30,7 +30,7 @@ i18n
},
backend: {
loadPath: "/locales/{{lng}}.json",
},
} satisfies HttpBackendOptions,
});

import.meta.hot?.on("locales-update", () => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"postcss.config.cjs",
"tailwind.config.cjs",
"tailwind.templates.config.cjs",
"codegen.ts"
"codegen.ts",
"i18next-parser.config.ts"
]
}

0 comments on commit 5f7bc2a

Please sign in to comment.