Skip to content

Commit

Permalink
fix(map): fix localization complex adjectives such as half-species
Browse files Browse the repository at this point in the history
fixes #8
  • Loading branch information
MichaelMakesGames committed Aug 20, 2024
1 parent b1120c3 commit 213f90a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/renderer/src/lib/map/data/locUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ export function localizeTextSync(
const var0 = text.variables?.[0];
if (!var0 || !var0.value?.variables) throw new Error();
const adj = loc[var0.value.key] ?? var0.value.key;
if (adj.includes('$1$')) {
if (adj.match(/\$\w+\$/)) {
return localizeTextSync(var0.value, loc);
} else {
return (loc['adj_format'] ?? 'adj $1$')
.replace('adj', adj)
.replace('$1$', localizeTextSync(var0.value.variables[0]?.value, loc));
.replace(
'$1$',
localizeTextSync(var0.value.variables.find((v) => v.key === '1')?.value, loc),
);
}
} catch {
console.warn('localization failed', text);
Expand Down

0 comments on commit 213f90a

Please sign in to comment.