mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 08:35:04 +00:00
better pattern name (#1885)
## Description: If the translation key isn't found for a pattern, show just the pattern key, not the entire translation key. Since patterns will be added frequently. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
committed by
Scott Anderson
parent
783a68e359
commit
8965ad53b0
@@ -144,7 +144,7 @@ export class TerritoryPatternsModal extends LitElement {
|
||||
@mouseleave=${() => this.handleMouseLeave()}
|
||||
>
|
||||
<div class="text-sm font-bold mb-1">
|
||||
${translateText(`territory_patterns.pattern.${pattern.name}`)}
|
||||
${translatePatternName("territory_patterns.pattern", pattern.name)}
|
||||
</div>
|
||||
<div
|
||||
class="preview-container"
|
||||
@@ -411,3 +411,12 @@ export function generatePreviewDataUrl(
|
||||
patternCache.set(pattern, dataUrl);
|
||||
return dataUrl;
|
||||
}
|
||||
|
||||
function translatePatternName(prefix: string, patternName: string): string {
|
||||
const translation = translateText(`${prefix}.${patternName}`);
|
||||
if (translation.startsWith(prefix)) {
|
||||
// Translation was not found, fallback to pattern name
|
||||
return patternName[0].toUpperCase() + patternName.substring(1);
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user