diff --git a/ui/merge-strings.js b/ui/merge-strings.js new file mode 100755 index 0000000..ccf624a --- /dev/null +++ b/ui/merge-strings.js @@ -0,0 +1,16 @@ +#!/bin/env node +const fs = require('fs') +const merge = require('deepmerge') +const glob = require('glob') + +glob('src/locales/!(messages).json', {}, (e, files) => { + let messages = [] + for (const file of files) { + console.log(`Loading ${file}...`) + const locale_messages = require(`./${file}`) + messages.push(locale_messages) + } + console.log('Merging messages...') + messages = merge.all(messages) + fs.writeFileSync('src/locales/messages.json', JSON.stringify(messages), {}) +}) diff --git a/ui/package.json b/ui/package.json index 6d6ea87..bb3baf9 100644 --- a/ui/package.json +++ b/ui/package.json @@ -5,7 +5,8 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "lint": "vue-cli-service lint" + "lint": "vue-cli-service lint", + "postinstall": "node merge-strings.js" }, "dependencies": { "axios": "^0.19.0", @@ -21,6 +22,7 @@ "@vue/cli-service": "^4.1.1", "@vue/eslint-config-standard": "^5.0.1", "babel-eslint": "^10.0.3", + "deepmerge": "^4.2.2", "eslint": "^6.7.2", "eslint-plugin-import": "^2.18.2", "eslint-plugin-node": "^10.0.0", @@ -28,6 +30,7 @@ "eslint-plugin-standard": "^4.0.1", "eslint-plugin-vue": "^6.0.1", "express": "^4.17.1", + "glob": "^7.1.6", "http-proxy-middleware": "^0.20.0", "vue-template-compiler": "^2.6.10" } diff --git a/ui/src/App.vue b/ui/src/App.vue index ec584d4..c3214d7 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -18,6 +18,14 @@

{{ $t('app.maintenance_title', {'name': $root.$data.attrs.name}) }}

+ + + + {{locale.locale}} + @@ -27,6 +35,33 @@ + +