Skip to content

Commit abb523c

Browse files
committed
Prevent double-fetch of translations
1 parent 94aeeba commit abb523c

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

frontend/src/@types/i18next.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
// Please see LICENSE in the repository root for full details.
66

77
import "i18next";
8-
import type frontend from "../../locales/en.json";
8+
import type translation from "../../locales/en.json";
99

1010
declare module "i18next" {
1111
interface CustomTypeOptions {
1212
keySeparator: ".";
1313
pluralSeparator: ":";
14-
defaultNS: "frontend";
14+
defaultNS: "translation";
1515
resources: {
16-
frontend: typeof frontend;
16+
translation: typeof translation;
1717
};
1818
}
1919
}

frontend/src/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ i18n
8989
fallbackLng: "en",
9090
keySeparator: ".",
9191
pluralSeparator: ":",
92-
defaultNS: "frontend",
92+
defaultNS: "translation",
9393
supportedLngs,
9494
interpolation: {
9595
escapeValue: false, // React has built-in XSS protections

frontend/src/i18n/password_changes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { SetPasswordStatus } from "../gql/graphql";
2121
* Throws an error if the status is not known.
2222
*/
2323
export function translateSetPasswordError(
24-
t: TFunction<"frontend", undefined>,
24+
t: TFunction,
2525
status: SetPasswordStatus | undefined,
2626
): string | undefined {
2727
switch (status) {

frontend/src/utils/password_complexity/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface PasswordComplexity {
7070
/** Estimates the complexity of a password. */
7171
export async function estimatePasswordComplexity(
7272
password: string,
73-
t: TFunction<"frontend", undefined>,
73+
t: TFunction,
7474
): Promise<PasswordComplexity> {
7575
const scorerResult = await zxcvbnAsync(password);
7676

@@ -96,10 +96,7 @@ export async function estimatePasswordComplexity(
9696
}
9797

9898
/** Returns a translated string corresponding to the 0 to 4 score. */
99-
function translateScore(
100-
score: 0 | 1 | 2 | 3 | 4,
101-
t: TFunction<"frontend", undefined>,
102-
): string {
99+
function translateScore(score: 0 | 1 | 2 | 3 | 4, t: TFunction): string {
103100
switch (score) {
104101
case 0:
105102
return t("frontend.password_strength.score.0");
@@ -117,7 +114,7 @@ function translateScore(
117114
/** Returns a translated string corresponding to a password improvement suggestion from zxcvbn-ts. */
118115
function translateSuggestion(
119116
suggestionCode: string,
120-
t: TFunction<"frontend", undefined>,
117+
t: TFunction,
121118
): string | undefined {
122119
switch (suggestionCode) {
123120
case "allUppercase":
@@ -154,7 +151,7 @@ function translateSuggestion(
154151
/** Returns a translated string corresponding to a weak password warning from zxcvbn-ts. */
155152
function translateWarning(
156153
warningCode: string,
157-
t: TFunction<"frontend", undefined>,
154+
t: TFunction,
158155
): string | undefined {
159156
switch (warningCode) {
160157
case "commonNames":

0 commit comments

Comments
 (0)