# HG changeset patch # User Thomas Junk # Date 1530632766 -7200 # Node ID 3d9341f6da4e26e6c62e2bc09587025a10fa2ebe # Parent 992e179124058fb1d2fc9984371bfdfb99749ffe feat: Locale of browser determines the default language The locale chosen by the user seems a sane default for the default loclae of the application. To safely determine the browsers locale, locale2 was chosen. Localizations were renewed. Configuration variable is no longer needed in .env.sample de_DE localization is not needed. de_AT is needed. diff -r 992e17912405 -r 3d9341f6da4e client/.env.sample --- a/client/.env.sample Tue Jul 03 16:18:29 2018 +0200 +++ b/client/.env.sample Tue Jul 03 17:46:06 2018 +0200 @@ -9,6 +9,3 @@ #Path of vendored images is copied during a webpack build VUE_APP_VENDOR_IMG_PATH= - -#Default Language, e.g. de_DE, en_GB -VUE_APP_DEFAULT_LANGUAGE= diff -r 992e17912405 -r 3d9341f6da4e client/Makefile --- a/client/Makefile Tue Jul 03 16:18:29 2018 +0200 +++ b/client/Makefile Tue Jul 03 17:46:06 2018 +0200 @@ -7,7 +7,7 @@ OUTPUT_DIR = src # Available locales for the app. -LOCALES = de_DE en_GB it_IT +LOCALES = de_AT en_GB # Name of the generated .po files for each available locale. LOCALE_FILES ?= $(patsubst %,$(OUTPUT_DIR)/locale/%/LC_MESSAGES/app.po,$(LOCALES)) diff -r 992e17912405 -r 3d9341f6da4e client/package.json --- a/client/package.json Tue Jul 03 16:18:29 2018 +0200 +++ b/client/package.json Tue Jul 03 17:46:06 2018 +0200 @@ -13,6 +13,7 @@ "axios": "^0.18.0", "bootstrap": "^4.1.1", "font-awesome": "^4.7.0", + "locale2": "^2.2.0", "ol": "^5.0.0", "vue": "^2.5.16", "vue-router": "^3.0.1", diff -r 992e17912405 -r 3d9341f6da4e client/src/locale/de_AT/LC_MESSAGES/app.po --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/locale/de_AT/LC_MESSAGES/app.po Tue Jul 03 17:46:06 2018 +0200 @@ -0,0 +1,39 @@ +# German translations for wamosjs package +# German translation for wamosjs. +# Copyright (C) 2018 THE wamosjs'S COPYRIGHT HOLDER +# This file is distributed under the same license as the wamosjs package. +# Automatically generated, 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: wamosjs 0.1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-03 17:00+0200\n" +"PO-Revision-Date: 2018-07-03 17:00+0200\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: de_AT\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/views/Login.vue:23 +msgid "Forgot password" +msgstr "Passwort vergessen" + +#: src/views/Login.vue:22 +msgid "Login" +msgstr "Login" + +#: src/views/Login.vue:11 +msgid "Login failed" +msgstr "Login fehlgeschlagen" + +#: src/views/Login.vue:115 +msgid "Enter passphrase" +msgstr "Passphrase" + +#: src/views/Login.vue:118 +msgid "Enter email" +msgstr "Email" diff -r 992e17912405 -r 3d9341f6da4e client/src/locale/de_DE/LC_MESSAGES/app.po --- a/client/src/locale/de_DE/LC_MESSAGES/app.po Tue Jul 03 16:18:29 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# German translations for wamosjs package -# German translation for wamosjs. -# Copyright (C) 2018 THE wamosjs'S COPYRIGHT HOLDER -# This file is distributed under the same license as the wamosjs package. -# Automatically generated, 2018. -# -msgid "" -msgstr "" -"Project-Id-Version: wamosjs 0.1.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-02 18:05+0200\n" -"PO-Revision-Date: 2018-07-02 18:04+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: de_DE\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: src/views/Login.vue:23 -msgid "Forgot password" -msgstr "Passwort vergessen" - -#: src/views/Login.vue:22 -msgid "Login" -msgstr "Login" - -#: src/views/Login.vue:11 -msgid "Login failed" -msgstr "Login fehlgeschlagen" - -#: src/views/Login.vue:115 -msgid "Enter passphrase" -msgstr "Passphrase" - -#: src/views/Login.vue:118 -msgid "Enter email" -msgstr "Email" diff -r 992e17912405 -r 3d9341f6da4e client/src/locale/de_DE/LC_MESSAGES/app.po~ --- a/client/src/locale/de_DE/LC_MESSAGES/app.po~ Tue Jul 03 16:18:29 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# German translations for wamosjs package -# German translation for wamosjs. -# Copyright (C) 2018 THE wamosjs'S COPYRIGHT HOLDER -# This file is distributed under the same license as the wamosjs package. -# Automatically generated, 2018. -# -msgid "" -msgstr "" -"Project-Id-Version: wamosjs 0.1.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-02 18:04+0200\n" -"PO-Revision-Date: 2018-07-02 18:04+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: de\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: src/views/Login.vue:23 -msgid "Forgot password" -msgstr "Passwort vergessen" - -#: src/views/Login.vue:22 -msgid "Login" -msgstr "Login" - -#: src/views/Login.vue:11 -msgid "Login failed" -msgstr "Login fehlgeschlagen" - -#: src/views/Login.vue:115 -msgid "Enter passphrase" -msgstr "Passphrase" - -#: src/views/Login.vue:118 -msgid "Enter email" -msgstr "Email" diff -r 992e17912405 -r 3d9341f6da4e client/src/locale/en_GB/LC_MESSAGES/app.po --- a/client/src/locale/en_GB/LC_MESSAGES/app.po Tue Jul 03 16:18:29 2018 +0200 +++ b/client/src/locale/en_GB/LC_MESSAGES/app.po Tue Jul 03 17:46:06 2018 +0200 @@ -7,8 +7,8 @@ msgstr "" "Project-Id-Version: wamosjs 0.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-02 18:05+0200\n" -"PO-Revision-Date: 2018-07-02 18:04+0200\n" +"POT-Creation-Date: 2018-07-03 17:18+0200\n" +"PO-Revision-Date: 2018-07-03 17:18+0200\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: en_GB\n" @@ -34,6 +34,5 @@ msgstr "Enter passphrase" #: src/views/Login.vue:118 -#, fuzzy msgid "Enter email" -msgstr "Enter email." +msgstr "Enter email" diff -r 992e17912405 -r 3d9341f6da4e client/src/locale/en_GB/LC_MESSAGES/app.po~ --- a/client/src/locale/en_GB/LC_MESSAGES/app.po~ Tue Jul 03 16:18:29 2018 +0200 +++ b/client/src/locale/en_GB/LC_MESSAGES/app.po~ Tue Jul 03 17:46:06 2018 +0200 @@ -1,38 +0,0 @@ -# English translations for wamosjs package. -# Copyright (C) 2018 THE wamosjs'S COPYRIGHT HOLDER -# This file is distributed under the same license as the wamosjs package. -# Automatically generated, 2018. -# -msgid "" -msgstr "" -"Project-Id-Version: wamosjs 0.1.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-02 18:04+0200\n" -"PO-Revision-Date: 2018-07-02 18:04+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: en_GB\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: src/views/Login.vue:23 -msgid "Forgot password" -msgstr "Forgot password" - -#: src/views/Login.vue:22 -msgid "Login" -msgstr "Login" - -#: src/views/Login.vue:11 -msgid "Login failed" -msgstr "Login failed" - -#: src/views/Login.vue:115 -msgid "Enter passphrase" -msgstr "Enter passphrase" - -#: src/views/Login.vue:118 -msgid "Enter email." -msgstr "Enter email." diff -r 992e17912405 -r 3d9341f6da4e client/src/locale/it_IT/LC_MESSAGES/app.po --- a/client/src/locale/it_IT/LC_MESSAGES/app.po Tue Jul 03 16:18:29 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# Italian translations for wamosjs package -# Traduzioni italiane per il pacchetto wamosjs.. -# Copyright (C) 2018 THE wamosjs'S COPYRIGHT HOLDER -# This file is distributed under the same license as the wamosjs package. -# Automatically generated, 2018. -# -msgid "" -msgstr "" -"Project-Id-Version: wamosjs 0.1.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-02 18:05+0200\n" -"PO-Revision-Date: 2018-07-02 18:04+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: it_IT\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: src/views/Login.vue:23 -msgid "Forgot password" -msgstr "" - -#: src/views/Login.vue:22 -msgid "Login" -msgstr "" - -#: src/views/Login.vue:11 -msgid "Login failed" -msgstr "" - -#: src/views/Login.vue:115 -msgid "Enter passphrase" -msgstr "" - -#: src/views/Login.vue:118 -msgid "Enter email" -msgstr "" diff -r 992e17912405 -r 3d9341f6da4e client/src/locale/it_IT/LC_MESSAGES/app.po~ --- a/client/src/locale/it_IT/LC_MESSAGES/app.po~ Tue Jul 03 16:18:29 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# Italian translations for wamosjs package -# Traduzioni italiane per il pacchetto wamosjs.. -# Copyright (C) 2018 THE wamosjs'S COPYRIGHT HOLDER -# This file is distributed under the same license as the wamosjs package. -# Automatically generated, 2018. -# -msgid "" -msgstr "" -"Project-Id-Version: wamosjs 0.1.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-02 18:04+0200\n" -"PO-Revision-Date: 2018-07-02 18:04+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: it\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: src/views/Login.vue:23 -msgid "Forgot password" -msgstr "" - -#: src/views/Login.vue:22 -msgid "Login" -msgstr "" - -#: src/views/Login.vue:11 -msgid "Login failed" -msgstr "" - -#: src/views/Login.vue:115 -msgid "Enter passphrase" -msgstr "" - -#: src/views/Login.vue:118 -msgid "Enter email." -msgstr "" diff -r 992e17912405 -r 3d9341f6da4e client/src/main.js --- a/client/src/main.js Tue Jul 03 16:18:29 2018 +0200 +++ b/client/src/main.js Tue Jul 03 17:46:06 2018 +0200 @@ -4,22 +4,33 @@ import store from "./store"; import GetTextPlugin from "vue-gettext"; import translations from "./translations.json"; +import locale2 from "locale2"; +import "../node_modules/bootstrap/dist/css/bootstrap.min.css"; +import "../node_modules/font-awesome/css/font-awesome.min.css"; +import "../node_modules/ol/ol.css"; -const defaultLanguage = process.env.VUE_APP_DEFAULT_LANGUAGE || "de_DE"; +let browserLanguage = locale2; + +// planned also SK, HU, HR, RS, BiH, BG, RO, UA +const supportedLanguages = { + en_GB: "British English", + de_AT: "Deutsch" +}; + +if (browserLanguage === "de-DE") { + browserLanguage = "de-AT"; // map german to austrian variant for now +} + +const language = browserLanguage.replace("-", "_"); +const isLanguageAvailable = supportedLanguages[language]; +let defaultLanguage = isLanguageAvailable ? language : "en_GB"; Vue.use(GetTextPlugin, { translations: translations, - availableLanguages: { - en_GB: "British English", - de_DE: "Deutsch" - }, + availableLanguages: supportedLanguages, defaultLanguage: defaultLanguage }); -import "../node_modules/bootstrap/dist/css/bootstrap.min.css"; -import "../node_modules/font-awesome/css/font-awesome.min.css"; -import "../node_modules/ol/ol.css"; - Vue.config.productionTip = false; new Vue({ diff -r 992e17912405 -r 3d9341f6da4e client/src/translations.json --- a/client/src/translations.json Tue Jul 03 16:18:29 2018 +0200 +++ b/client/src/translations.json Tue Jul 03 17:46:06 2018 +0200 @@ -1,1 +1,1 @@ -{"de_DE":{"Forgot password":"Passwort vergessen","Login":"Login","Login failed":"Login fehlgeschlagen","Enter passphrase":"Passphrase","Enter email":"Email"},"en_GB":{"Forgot password":"Forgot password","Login":"Login","Login failed":"Login failed","Enter passphrase":"Enter passphrase"},"it_IT":{}} \ No newline at end of file +{"de_AT":{"Forgot password":"Passwort vergessen","Login":"Login","Login failed":"Login fehlgeschlagen","Enter passphrase":"Passphrase","Enter email":"Email"},"en_GB":{"Forgot password":"Forgot password","Login":"Login","Login failed":"Login failed","Enter passphrase":"Enter passphrase","Enter email":"Enter email"}} \ No newline at end of file diff -r 992e17912405 -r 3d9341f6da4e client/yarn.lock --- a/client/yarn.lock Tue Jul 03 16:18:29 2018 +0200 +++ b/client/yarn.lock Tue Jul 03 17:46:06 2018 +0200 @@ -5238,6 +5238,10 @@ emojis-list "^2.0.0" json5 "^0.5.0" +locale2@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/locale2/-/locale2-2.2.0.tgz#8efe70ce39b5a7917f1ef5b469df7f1c1f5ccad4" + locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"