Skip to content

Commit

Permalink
fix(translations): changes rs and rs-Latin dateFNSkey to proper local…
Browse files Browse the repository at this point in the history
…e instead of en-US (payloadcms#9621)

### What?
Adds Serbian `rs` and `rs-Latin` to `importDateFNSLocale` as well as
changes their `dateFNSKey` in the language definition to the appropriate
key instead of `en-US`

### Why?
To support Serbian language with appropriately localized dates.

### How?
Minor changes in translations package.
  • Loading branch information
akhrarovsaid authored Dec 1, 2024
1 parent e6ea68e commit 2b4522b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/translations/src/importDateFNSLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ export const importDateFNSLocale = async (locale: string): Promise<Locale> => {
case 'ro':
result = (await import('date-fns/locale/ro')).ro

break
case 'rs':
result = (await import('date-fns/locale/sr')).sr

break
case 'rs-Latin':
result = (await import('date-fns/locale/sr-Latn')).srLatn

break
case 'ru':
result = (await import('date-fns/locale/ru')).ru
Expand Down
2 changes: 1 addition & 1 deletion packages/translations/src/languages/rs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,6 @@ export const rsTranslations: DefaultTranslationsObject = {
}

export const rs: Language = {
dateFNSKey: 'en-US',
dateFNSKey: 'rs',
translations: rsTranslations,
}
2 changes: 1 addition & 1 deletion packages/translations/src/languages/rsLatin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,6 @@ export const rsLatinTranslations: DefaultTranslationsObject = {
}

export const rsLatin: Language = {
dateFNSKey: 'en-US',
dateFNSKey: 'rs-Latin',
translations: rsLatinTranslations,
}
2 changes: 2 additions & 0 deletions packages/translations/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type DateFNSKeys =
| 'pl'
| 'pt'
| 'ro'
| 'rs'
| 'rs-Latin'
| 'ru'
| 'sk'
| 'sl-SI'
Expand Down

0 comments on commit 2b4522b

Please sign in to comment.