Skip to content

Commit

Permalink
fix admin translation loading issue (#5956)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs authored Jun 21, 2024
1 parent f7d4d45 commit ad9d30f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion frontend/app/src/components/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import IncomingCall from "./home/video/IncomingCall.svelte";
import InstallPrompt from "./home/InstallPrompt.svelte";
import NotificationsBar from "./home/NotificationsBar.svelte";
import { reviewingTranslations } from "../i18n/i18n";
overrideItemIdKeyNameBeforeInitialisingDndZones("_id");
Expand Down Expand Up @@ -428,7 +429,7 @@
{:else if $identityState.kind === "upgrading_user" || $identityState.kind === "upgrade_user"}
<Upgrading />
{:else if $identityState.kind === "anon" || $identityState.kind === "logging_in" || $identityState.kind === "registering" || $identityState.kind === "logged_in" || $identityState.kind === "loading_user" || $identityState.kind === "challenging"}
{#if !$isLoading}
{#if !$isLoading || $reviewingTranslations}
<Router
on:hangup={hangup}
on:askToSpeak={askToSpeak}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
RejectReason,
TranslationCorrection,
} from "openchat-client";
import { getContext, onMount } from "svelte";
import { getContext, onDestroy, onMount } from "svelte";
import { iconSize } from "../../../stores/iconSize";
import { toastStore } from "../../../stores/toast";
import { i18nKey } from "../../../i18n/i18n";
import { i18nKey, reviewingTranslations } from "../../../i18n/i18n";
import { menuCloser } from "../../../actions/closeMenu";
const client = getContext<OpenChat>("client");
Expand All @@ -35,12 +35,15 @@
$: formattedBalance = client.formatTokens(chatBalance, 8);
onMount(async () => {
reviewingTranslations.set(true);
await client.getProposedTranslationCorrections().then(async (res) => {
corrections = await loadRequiredLocales(flattenCorrections(res));
});
refreshBalance();
});
onDestroy(() => reviewingTranslations.set(false));
// Since the locales are lazy loaded, we need to determine the locales for which we have corrections
// and trigger the loading of the current translations for each of those locales.
async function loadRequiredLocales(
Expand All @@ -51,9 +54,9 @@
all.add(c.locale);
return all;
}, new Set<string>());
await [...locales].reduce((p, l) => {
return p.then(() => locale.set(l));
}, Promise.resolve());
for (const l of locales) {
await locale.set(l);
}
await locale.set(currentLocale);
return corrections;
}
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export function interpolate(

export const editmode = writable<boolean>(false);
export const editingLabel = writable<ResourceKey | undefined>(undefined);
export const reviewingTranslations = writable<boolean>(false);

export function i18nKey(
key: string,
Expand Down

0 comments on commit ad9d30f

Please sign in to comment.