Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-02-03 22:29:02 +0300
committerJulius Härtl <jus@bitgrid.net>2020-03-29 15:40:07 +0300
commit78e220daad36917d65ffae159f7aba99cf60cbfc (patch)
treeac4cfd7484482c93eeea11e8269e457f27490e29 /src
parente7d83b9c955e658e5fef9e7148018ebc9fd82d75 (diff)
Fix lang handling
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src')
-rw-r--r--src/helpers/index.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/helpers/index.js b/src/helpers/index.js
index 31cf98b4..d473571f 100644
--- a/src/helpers/index.js
+++ b/src/helpers/index.js
@@ -23,9 +23,30 @@
import { getLanguage, getLocale } from 'nextcloud-l10n'
const languageToBCP47 = () => {
+ let language = getLanguage().replace(/_/g, '-')
+ let locale = getLocale()
+
+ // German formal should just be treated as 'de'
+ if (language === 'de-DE') {
+ language = 'de'
+ }
+ // special case where setting the bc47 region depending on the locale setting makes sense
+ const whitelist = {
+ de: {
+ 'de_CH': 'de-CH',
+ 'gsw': 'de-CH',
+ 'gsw_CH': 'de-CH'
+ }
+ }
+ const matchingWhitelist = whitelist[language]
+ if (typeof matchingWhitelist !== 'undefined' && typeof matchingWhitelist[locale] !== 'undefined') {
+ return matchingWhitelist[locale]
+ }
+
// loleaflet expects a BCP47 language tag syntax
- return (getLanguage() + '-' + getLocale())
- .replace(/^([a-z]{2}).*_([A-Z]{2})$/, (match, p1, p2) => p1 + '-' + p2.toLowerCase())
+ // when a the nextcloud language constist of two parts we sent both
+ // as the region is then provided by the language setting
+ return language
}
const getNextcloudVersion = () => {