Skip to content

Commit

Permalink
Add en-GB localisation (#5952)
Browse files Browse the repository at this point in the history
* Create blank en-GB/messages.po

* localise certain strings for en-GB

* Update lingui.config.js

* Update dates.ts

* Update helpers.ts

* Update i18n.ts

* Update i18n.web.ts

* Update languages.ts

* Update i18n.ts
  • Loading branch information
surfdude29 authored Oct 28, 2024
1 parent cd6fc13 commit 498b83a
Show file tree
Hide file tree
Showing 7 changed files with 7,946 additions and 0 deletions.
1 change: 1 addition & 0 deletions lingui.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
'en',
'ca',
'de',
'en-GB',
'es',
'fi',
'fr',
Expand Down
2 changes: 2 additions & 0 deletions src/components/hooks/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {formatDistance, Locale} from 'date-fns'
import {
ca,
de,
enGB,
es,
fi,
fr,
Expand Down Expand Up @@ -39,6 +40,7 @@ const locales: Record<AppLanguage, Locale | undefined> = {
en: undefined,
ca,
de,
['en-GB']: enGB,
es,
fi,
fr,
Expand Down
2 changes: 2 additions & 0 deletions src/locale/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
return AppLanguage.ca
case 'de':
return AppLanguage.de
case 'en-GB':
return AppLanguage.en_GB
case 'es':
return AppLanguage.es
case 'fi':
Expand Down
9 changes: 9 additions & 0 deletions src/locale/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {AppLanguage} from '#/locale/languages'
import {messages as messagesCa} from '#/locale/locales/ca/messages'
import {messages as messagesDe} from '#/locale/locales/de/messages'
import {messages as messagesEn} from '#/locale/locales/en/messages'
import {messages as messagesEn_GB} from '#/locale/locales/en-GB/messages'
import {messages as messagesEs} from '#/locale/locales/es/messages'
import {messages as messagesFi} from '#/locale/locales/fi/messages'
import {messages as messagesFr} from '#/locale/locales/fr/messages'
Expand Down Expand Up @@ -53,6 +54,14 @@ export async function dynamicActivate(locale: AppLanguage) {
])
break
}
case AppLanguage.en_GB: {
i18n.loadAndActivate({locale, messages: messagesEn_GB})
await Promise.all([
import('@formatjs/intl-pluralrules/locale-data/en'),
import('@formatjs/intl-numberformat/locale-data/en-GB'),
])
break
}
case AppLanguage.es: {
i18n.loadAndActivate({locale, messages: messagesEs})
await Promise.all([
Expand Down
4 changes: 4 additions & 0 deletions src/locale/i18n.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export async function dynamicActivate(locale: AppLanguage) {
mod = await import(`./locales/de/messages`)
break
}
case AppLanguage.en_GB: {
mod = await import(`./locales/en-GB/messages`)
break
}
case AppLanguage.es: {
mod = await import(`./locales/es/messages`)
break
Expand Down
2 changes: 2 additions & 0 deletions src/locale/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum AppLanguage {
en = 'en',
ca = 'ca',
de = 'de',
en_GB = 'en-GB',
es = 'es',
fi = 'fi',
fr = 'fr',
Expand Down Expand Up @@ -35,6 +36,7 @@ export const APP_LANGUAGES: AppLanguageConfig[] = [
{code2: AppLanguage.en, name: 'English'},
{code2: AppLanguage.ca, name: 'Català – Catalan'},
{code2: AppLanguage.de, name: 'Deutsch – German'},
{code2: AppLanguage.en_GB, name: 'English (UK)'},
{code2: AppLanguage.es, name: 'Español – Spanish'},
{code2: AppLanguage.fi, name: 'Suomi – Finnish'},
{code2: AppLanguage.fr, name: 'Français – French'},
Expand Down
Loading

0 comments on commit 498b83a

Please sign in to comment.