Skip to content

Commit

Permalink
feat: 🎸 Latin and fix for locales
Browse files Browse the repository at this point in the history
  • Loading branch information
kajetan-kazimierczak committed Nov 16, 2021
1 parent eed2a75 commit 1c05196
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions apps/skolplattformen-sthlm/services/languageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'moment/locale/nl'
import 'moment/locale/pl'
import 'moment/locale/ru'
import 'moment/locale/sv'
import 'moment/locale/uz-latn'
import 'moment/locale/zh-cn'
import { I18nManager } from 'react-native'

Expand All @@ -40,6 +39,13 @@ export const isRTL = (langCode: string) => {
return rtlList[langCode]
}

const getCorrespondingMomentLocale = (langCode?: string): string => {
if(langCode === 'la') return 'sv'
if(langCode === 'nb_NO') return 'nb'
if(langCode === 'zh_Hant' || langCode === 'zh_Hans') return 'zh-cn'
return langCode!
}

export const LanguageService = {
get: () => Strings,
getLanguageCode: () => languageCode,
Expand All @@ -53,7 +59,7 @@ export const LanguageService = {
i18n.locale = langCode
I18nManager.forceRTL(isRTL(langCode))
}
moment.locale(langCode)
moment.locale(getCorrespondingMomentLocale(langCode))
},
setLanguageCode: ({ langCode }: { langCode?: string }) => {
if (langCode && allString[langCode]) {
Expand All @@ -69,7 +75,6 @@ export const LanguageService = {
})
return Strings
},

onChange: ({ key }: { key: string }, cb: (langCode: string) => void) => {
const unsubscribe = () => {
delete changeListeners[key]
Expand Down
2 changes: 1 addition & 1 deletion apps/skolplattformen-sthlm/utils/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const languages: Language[] = [
langCode: 'la',
languageName: 'Latin',
languageLocalName: 'Latina',
active: false,
active: true,
},
{
langCode: 'nb_NO',
Expand Down

0 comments on commit 1c05196

Please sign in to comment.