From dae3f676c5ff69667972b9676b3b0e4402ce5264 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Thu, 9 Jun 2022 15:43:42 +0200 Subject: [PATCH] Added central function for getting system language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hard coded "nb" (Norwegian bokmål) for now --- src/components/CommonUtil.vue | 9 +++++++++ src/components/Observation.vue | 14 ++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/CommonUtil.vue b/src/components/CommonUtil.vue index 9f41a73..f3df148 100644 --- a/src/components/CommonUtil.vue +++ b/src/components/CommonUtil.vue @@ -83,6 +83,15 @@ setHeaderTitle: function (headerTitle) { document.getElementById("appHeader").innerHTML = headerTitle; + }, + getSystemLocale: function() { + return "nb"; + // TODO: Enable this when more languages are supported + /* + return typeof navigator.language != 'undefined' ? + navigator.language.trim().substring(0, 2) + : null; + */ } } </script> \ No newline at end of file diff --git a/src/components/Observation.vue b/src/components/Observation.vue index faeeb35..b2799e7 100644 --- a/src/components/Observation.vue +++ b/src/components/Observation.vue @@ -478,7 +478,7 @@ let cropName = jsonDetailCrop.latinName; if (organismLocaleSet) { - let strLocale = This.getSystemLocale(); + let strLocale = CommonUtil.getSystemLocale(); organismLocaleSet.forEach(function (localObj) { @@ -518,7 +518,7 @@ let organismLocaleSet = jsonDetailPest.organismLocaleSet; if (organismLocaleSet) { - let strLocale = This.getSystemLocale(); + let strLocale = CommonUtil.getSystemLocale(); organismLocaleSet.forEach(localObj => { if (localObj.organismLocalePK.locale === strLocale) { if (localObj.localName) { @@ -663,16 +663,6 @@ updateQuntificationData(schemaData) { this.observation.observationData = schemaData; }, - getSystemLocale() { - var localePrefer = null; - var localePrefer2 = null; - if (typeof navigator.language != 'undefined') { - localePrefer = navigator.language; - localePrefer2 = localePrefer.trim().substring(0, 2); - } - - return localePrefer2; - }, }, filters: { -- GitLab