* origin/develop: (25 commits) force panel headers to be square on mobile (for now?) fix gap between panel heading and timeline menu Fix Open Chat button fix? fix Revert "Merge branch 'revert-a88abc7e' into 'develop'" Revert "Merge branch 'from/develop/tusooa/lang-opts' into 'develop'" Fix registration error stick chat scroll to bottom to help with OSK resizing the viewport Pass file name of cropped avatar to form data Add English translation for filtering end-of-poll notifications Add settings for filtering end-of-poll notifications Add English translations for poll-end notifications Show poll-end notifications Fix virtual scrolling when the user has a lot of pinned statuses Update dependency @vuelidate/core to v2.0.0-alpha.41 Make lint happy Make lint happy Add English translation for language options Add email language option to registration form ...merge-requests/1699/head
commit
1154a6514b
@ -1,12 +1,35 @@
|
||||
import languagesObject from '../../i18n/messages'
|
||||
import ISO6391 from 'iso-639-1'
|
||||
import _ from 'lodash'
|
||||
|
||||
const specialLanguageCodes = {
|
||||
'ja_easy': 'ja',
|
||||
'zh_Hant': 'zh-HANT'
|
||||
'zh_Hant': 'zh-HANT',
|
||||
'zh': 'zh-Hans'
|
||||
}
|
||||
|
||||
const internalToBrowserLocale = code => specialLanguageCodes[code] || code
|
||||
|
||||
const internalToBackendLocale = code => internalToBrowserLocale(code).replace('_', '-')
|
||||
|
||||
const getLanguageName = (code) => {
|
||||
const specialLanguageNames = {
|
||||
'ja_easy': 'やさしいにほんご',
|
||||
'zh': '简体中文',
|
||||
'zh_Hant': '繁體中文'
|
||||
}
|
||||
const languageName = specialLanguageNames[code] || ISO6391.getNativeName(code)
|
||||
const browserLocale = internalToBrowserLocale(code)
|
||||
return languageName.charAt(0).toLocaleUpperCase(browserLocale) + languageName.slice(1)
|
||||
}
|
||||
|
||||
const languages = _.map(languagesObject.languages, (code) => ({ code: code, name: getLanguageName(code) })).sort((a, b) => a.name.localeCompare(b.name))
|
||||
|
||||
const localeService = {
|
||||
internalToBrowserLocale
|
||||
internalToBrowserLocale,
|
||||
internalToBackendLocale,
|
||||
languages,
|
||||
getLanguageName
|
||||
}
|
||||
|
||||
export default localeService
|
||||
|
Loading…
Reference in new issue