Skip to content

Commit

Permalink
hotfix puzzle theme translations after #16223
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 20, 2024
1 parent e6e3beb commit c664cd0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ui/puzzle/src/view/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const invisibleThemes = new Set(['master', 'masterVsMaster', 'superGM']);
const editor = (ctrl: PuzzleCtrl): VNode[] => {
const data = ctrl.data,
votedThemes = ctrl.round?.themes || ({} as RoundThemes);
const trans = i18n.puzzleTheme as any;
const themeTrans = (key: string) => (i18n.puzzleTheme as any)[key] || key;
const visibleThemes: ThemeKey[] = [
...data.puzzle.themes.filter(t => !invisibleThemes.has(t)),
...Object.keys(votedThemes).filter(
Expand All @@ -58,7 +58,7 @@ const editor = (ctrl: PuzzleCtrl): VNode[] => {
].sort();
const allThemes = location.pathname == '/training/daily' ? null : ctrl.allThemes;
const availableThemes = allThemes ? allThemes.dynamic.filter((t: ThemeKey) => !votedThemes[t]) : null;
if (availableThemes) availableThemes.sort((a, b) => (trans(a) < trans(b) ? -1 : 1));
if (availableThemes) availableThemes.sort((a, b) => (themeTrans(a) < themeTrans(b) ? -1 : 1));
return [
h(
'div.puzzle__themes_list',
Expand All @@ -71,7 +71,11 @@ const editor = (ctrl: PuzzleCtrl): VNode[] => {
},
visibleThemes.map(key =>
h('div.puzzle__themes__list__entry', { class: { strike: votedThemes[key] === false } }, [
h('a', { attrs: { href: `/training/${key}`, title: trans(`${key}Description`) } }, trans(key)),
h(
'a',
{ attrs: { href: `/training/${key}`, title: themeTrans(`${key}Description`) } },
themeTrans(key),
),
allThemes &&
h(
'div.puzzle__themes__votes',
Expand Down Expand Up @@ -109,7 +113,11 @@ const editor = (ctrl: PuzzleCtrl): VNode[] => {
[
h('option', { attrs: { value: '', selected: true } }, i18n.puzzle.addAnotherTheme),
...availableThemes.map(theme =>
h('option', { attrs: { value: theme, title: trans(`${theme}Description`) } }, trans(theme)),
h(
'option',
{ attrs: { value: theme, title: themeTrans(`${theme}Description`) } },
themeTrans(theme),
),
),
],
),
Expand Down

0 comments on commit c664cd0

Please sign in to comment.