Skip to content
Snippets Groups Projects
Commit 0aad8930 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] Parameters > Language: new view to select prefered interface language

parent 9e30bdcf
Branches
No related tags found
No related merge requests found
export const Constants = {
API_URL: process.env.VUE_APP_REMOTE
API_URL: process.env.VUE_APP_REMOTE,
STORAGE_LANGUAGE: 'LANG',
DEFAULT_LANGUAGE: 'en',
FALLBACK_LANGUAGE: 'en',
}
export const RouteNames = {
......
import {lang} from '@/lib/i18n/lang'
export const i18nLangEn: lang = {
'app.loading': 'Loading...',
'init.title': 'Duniter node ready for sync.',
'init.node.select': 'Please select a node from which starting the sync:',
'init.message': 'This node looks like a fresh new install. You need to synchronize it with a Duniter currency network to continue.',
'init.node.g1.currency': 'Ğ1 currency',
'init.node.gt.currency': 'Ğ1-Test currency',
'init.sync.start': 'Synchronize',
'init.failed.no_node_found.title': 'Synchronization failed',
'init.failed.no_node_found.message': 'No node was able to give the next chunk of blocks.',
'init.failed.cannot_connect_to_remote.title': 'Synchronization failed',
'init.failed.cannot_connect_to_remote.message': 'Cannot connect to selected node.',
'sync.milestones': 'Milestones',
'sync.download': 'Download',
'sync.apply': 'Apply',
'sync.sandboxes': 'Sandboxes',
'sync.peers': 'Peers',
'menu.item.node': 'Node',
'menu.item.node.start': 'Start',
'menu.item.node.reset': 'Reset',
'parameters.menu.conf': 'Configuration file',
'parameters.menu.network': 'Network',
'parameters.conf.file.explanation': 'This is your configuration file. You can directly edit it from here if you wish.',
'fork.view.too.much': 'Too much blocks requested: max is {0}.',
'parameters.menu.lang': 'Language',
}
\ No newline at end of file
import {lang} from '@/lib/i18n/lang'
export const i18nLangFr: lang = {
'app.loading': 'Chargement de l\'application...',
'init.title': 'Nœud Duniter prêt pour la synchronisation.',
'init.node.select': 'Sélectionner un nœud à partir duquel synchroniser :',
'init.message': 'Ce nœud semble tout neuf. Vous devez le synchroniser pour continuer.',
'init.node.g1.currency': 'Monnaie Ğ1',
'init.node.gt.currency': 'Monnaie ĞTest',
'init.sync.start': 'Synchroniser',
'init.failed.no_node_found.title': 'La synchronisation a échoué',
'init.failed.no_node_found.message': 'Aucun nœud n\'a pu transmettre la prochaine tranche de blocs.',
'init.failed.cannot_connect_to_remote.title': 'La synchronisation a échoué',
'init.failed.cannot_connect_to_remote.message': 'Connexion au nœud sélectionnné impossible.',
'sync.milestones': 'Jalons',
'sync.download': 'Téléchargement',
'sync.apply': 'Application',
'sync.sandboxes': 'Piscines',
'sync.peers': 'Pairs',
'menu.item.node': 'Nœud',
'menu.item.node.start': 'Démarrer',
'menu.item.node.reset': 'Réinitialiser',
'parameters.menu.conf': 'Fichier de configuration',
'parameters.menu.network': 'Réseau',
'parameters.conf.file.explanation': 'Ceci est votre fichier de configuration. Vous pouvez le modifier directement ici si vous le souhaitez.',
'fork.view.too.much': 'Trop de blocs demandés : le maximum est de {0}.',
'parameters.menu.lang': 'Langage',
}
\ No newline at end of file
export interface lang {
'app.loading': string
'init.title': string
'init.node.select': string
'init.message': string
'init.node.g1.currency': string
'init.node.gt.currency': string
'init.sync.start': string
'init.failed.no_node_found.title': string
'init.failed.no_node_found.message': string
'init.failed.cannot_connect_to_remote.title': string
'init.failed.cannot_connect_to_remote.message': string
'sync.milestones': string
'sync.download': string
'sync.apply': string
'sync.sandboxes': string
'sync.peers': string
'menu.item.node': string
'menu.item.node.start': string
'menu.item.node.reset': string
'parameters.menu.conf': string
'parameters.menu.network': string
'parameters.conf.file.explanation': string
'fork.view.too.much': string
'parameters.menu.lang': string
}
export const i18nMessages = {
en: {
'app.loading': 'Loading...',
'init.title': 'Duniter node ready for sync.',
'init.node.select': 'Please select a node from which starting the sync:',
'init.message': 'This node looks like a fresh new install. You need to synchronize it with a Duniter currency network to continue.',
'init.node.g1.currency': 'Ğ1 currency',
'init.node.gt.currency': 'Ğ1-Test currency',
'init.sync.start': 'Synchronize',
'init.failed.no_node_found.title': 'Synchronization failed',
'init.failed.no_node_found.message': 'No node was able to give the next chunk of blocks.',
'init.failed.cannot_connect_to_remote.title': 'Synchronization failed',
'init.failed.cannot_connect_to_remote.message': 'Cannot connect to selected node.',
'sync.milestones': 'Milestones',
'sync.download': 'Download',
'sync.apply': 'Apply',
'sync.sandboxes': 'Sandboxes',
'sync.peers': 'Peers',
'menu.item.node': 'Node',
'menu.item.node.start': 'Start',
'menu.item.node.reset': 'Reset'
}
}
......@@ -43,7 +43,11 @@
</b-nav-item>
<b-nav-item><button class="btn" routerLink="params"><font-awesome-icon icon="cog"/></button></b-nav-item>
<b-nav-item>
<router-link to="/home/parameters">
<button class="btn"><font-awesome-icon icon="cog"/></button>
</router-link>
</b-nav-item>
</b-navbar-nav>
</b-collapse>
......
<style lang="css" scoped>
</style>
<template>
<div class="container-fluid m-0 p-0">
<div class="row mt-2">
<div class="col-2">
<div class="nav flex-column nav-pills">
<router-link :to="menu.route" v-for="menu in menus" :key="menu.route">
<span class="nav-link" :class="{ 'active': currentRoute === menu.route }">{{ $t(menu.name )}}</span>
</router-link>
</div>
</div>
<div class="col-10">
<router-view></router-view>
</div>
</div>
</div>
</template>
<script lang="ts">
import {Component, Vue} from 'vue-property-decorator';
@Component({
components: {},
})
export default class extends Vue {
menus = [
{ route: '/home/parameters/lang', name: 'parameters.menu.lang' },
]
get currentRoute() {
return this.$route.path
}
}
</script>
<style lang="css" scoped>
</style>
<template>
<div>
<select v-model="lang" @change="changeLocale">
<option value="en">English</option>
<option value="fr">Français</option>
</select>
</div>
</template>
<script lang="ts">
import {Component, Vue} from 'vue-property-decorator';
import {Constants} from "@/lib/constants";
@Component({
components: {},
})
export default class extends Vue {
lang: string = ''
mounted() {
this.lang = this.$i18n.locale
}
changeLocale() {
this.$i18n.locale = this.lang
localStorage.setItem(Constants.STORAGE_LANGUAGE, this.lang)
}
}
</script>
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import {i18nMessages} from '@/lib/messages'
import {i18nLangEn} from '@/lib/i18n/en'
import {i18nLangFr} from '@/lib/i18n/fr'
import {Constants} from '@/lib/constants'
export const i18nMessages = {
en: (i18nLangEn as any),
fr: (i18nLangFr as any),
}
let browserLanguage = navigator.language || (navigator as any).userLanguage
if (browserLanguage) {
if (browserLanguage.match(/fr-FR/)) {
browserLanguage = 'fr'
}
else if (browserLanguage.match(/en-.*/)) {
browserLanguage = 'en'
}
else {
browserLanguage = Constants.DEFAULT_LANGUAGE
}
}
Vue.use(VueI18n)
export default new VueI18n({
locale: 'en',
fallbackLocale: 'en',
locale: localStorage.getItem(Constants.STORAGE_LANGUAGE) || browserLanguage,
fallbackLocale: Constants.FALLBACK_LANGUAGE,
messages: i18nMessages
})
\ No newline at end of file
......@@ -5,7 +5,9 @@ import Home from '@/views/Home.vue'
import Loader from '@/views/Loader.vue'
import Sync from '@/views/Sync.vue'
import Overview from '@/views/home/Overview.vue'
import Parameters from '@/views/home/Parameters.vue'
import Forkview from '@/views/home/Forkview.vue'
import Language from '@/views/home/parameters/Language.vue'
Vue.use(Router)
......@@ -35,8 +37,28 @@ export default new Router({
path: 'forkview',
name: 'forkview',
component: Forkview
},{
path: 'parameters',
name: 'parameters',
component: Parameters,
children: [{
path: 'lang',
name: 'lang',
component: Language
}]
}]
},
/*
{
path: '',
name: 'conf',
component: Conf
},{
path: 'network',
name: 'network',
component: Network
},
*/
{
path: '/about',
name: 'about',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment