Skip to content

Commit

Permalink
Simplify english locale translations into one
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusKjeldgaard committed Nov 21, 2024
1 parent 0f7353d commit 71a0512
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
11 changes: 6 additions & 5 deletions libs/designsystem/shared/src/translation/translation.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Inject, LOCALE_ID } from '@angular/core';
import { da } from './translations/da';
import { enUS } from './translations/en-us';
import { en } from './translations/en';
import { Translation } from './translation.interface';

@Injectable({
Expand All @@ -10,20 +10,21 @@ import { Translation } from './translation.interface';
export class TranslationService {
private translations: { [key: string]: Translation } = {
da,
'en-US': enUS,
en,
};

public currentTranslation: Translation = enUS;
public currentTranslation: Translation = en;

constructor(@Inject(LOCALE_ID) private localeId: string) {
this.setCurrentTranslation(localeId);
}

setCurrentTranslation(localeId: string): string {
const translation = this.translations[localeId];
const baseLocaleId = localeId.split('-')[0];
const translation = this.translations[baseLocaleId];

if (!translation) {
console.warn(`Translation not found for locale "${this.localeId}", falling back to "en-US"`);
console.warn(`Translation not found for locale "${this.localeId}", falling back to "en"`);
return;
}

Expand Down
12 changes: 0 additions & 12 deletions libs/designsystem/shared/src/translation/translations/en-gb.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Translation } from '../translation.interface';

export const enUS: Translation = {
export const en: Translation = {
back: 'Back',
close: 'Close',
nextMonth: 'Next month',
Expand Down

0 comments on commit 71a0512

Please sign in to comment.