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

Add support for overriding strings in the app #7886

Merged
merged 8 commits into from
Mar 1, 2022
Merged
Prev Previous commit
Next Next commit
Appease the linter
  • Loading branch information
turt2live committed Feb 23, 2022
commit 17c509706224f8edbdd9cdccc71e3c24dc1b9c82
6 changes: 3 additions & 3 deletions src/languageHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ let cachedCustomTranslations: Optional<ICustomTranslations> = null;
let cachedCustomTranslationsExpire = 0; // zero to trigger expiration right away

export class CustomTranslationOptions {
public static LookupFn: (url: string) => ICustomTranslations;
public static lookupFn: (url: string) => ICustomTranslations;
turt2live marked this conversation as resolved.
Show resolved Hide resolved

private constructor() {
// static access for tests only
Expand All @@ -619,8 +619,8 @@ export async function registerCustomTranslations() {
try {
let json: ICustomTranslations;
if (Date.now() >= cachedCustomTranslationsExpire) {
json = CustomTranslationOptions.LookupFn
? CustomTranslationOptions.LookupFn(lookupUrl)
json = CustomTranslationOptions.lookupFn
? CustomTranslationOptions.lookupFn(lookupUrl)
: (await (await fetch(lookupUrl)).json() as ICustomTranslations);
cachedCustomTranslations = json;

Expand Down
4 changes: 2 additions & 2 deletions test/languageHandler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
describe('languageHandler', () => {
afterEach(() => {
SdkConfig.unset();
CustomTranslationOptions.LookupFn = undefined;
CustomTranslationOptions.lookupFn = undefined;
});

it('should support overriding translations', async () => {
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('languageHandler', () => {
SdkConfig.add({
custom_translations_url: lookupUrl,
});
CustomTranslationOptions.LookupFn = fn;
CustomTranslationOptions.lookupFn = fn;
await registerCustomTranslations();

await setLanguage("en");
Expand Down