diff --git a/ui/package.json b/ui/package.json index baea5b3..0cfbd8a 100644 --- a/ui/package.json +++ b/ui/package.json @@ -12,6 +12,7 @@ "buefy": "^0.8.5", "vue": "^2.6.10", "vue-axios": "^2.1.5", + "vue-i18n": "^8.15.0", "vue-router": "^3.1.3" }, "devDependencies": { diff --git a/ui/src/App.vue b/ui/src/App.vue index d5a5d19..ec584d4 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -9,14 +9,14 @@

- Welcome to the {{ $root.$data.attrs.name }} installer! + {{ $t('app.installer_title', {'name': $root.$data.attrs.name}) }}

- We will have you up and running in just a few moments. + {{ $t('app.installer_subtitle') }}

- Welcome to the {{ $root.$data.attrs.name }} Maintenance Tool. + {{ $t('app.maintenance_title', {'name': $root.$data.attrs.name}) }}

diff --git a/ui/src/locales/messages.js b/ui/src/locales/messages.js new file mode 100644 index 0000000..fb7e960 --- /dev/null +++ b/ui/src/locales/messages.js @@ -0,0 +1,54 @@ +export default { + en: { + app: { + installer_title: 'Welcome to the {name} installer!', + installer_subtitle: 'We will have you up and running in just a few moments.', + maintenance_title: 'Welcome to the {name} Maintenance Tool.', + window_title: '{name} Installer' + }, + download_config: { + download_config: 'Downloading config...', + error_download_config: 'Got error while downloading config: {msg}' + }, + select_packages: { + title: 'Select which packages you want to install:', + installed: '(installed)', + advanced: 'Advanced...', + install: 'Install', + modify: 'Modify', + location: 'Install Location', + location_placeholder: 'Enter a install path here', + select: 'Select' + }, + install_packages: { + check_for_update: 'Checking for updates...', + uninstall: 'Uninstalling...', + self_update: 'Downloading self-update...', + install: 'Installing...', + please_wait: 'Please wait...' + }, + error: { + title: 'An error occurred', + exit_error: '{msg}\n\nPlease upload the log file (in {path}) to the {name} team', + location_unknown: 'the location where this installer is' + }, + complete: { + thanks: 'Thanks for installing {name}!', + up_to_date: '{name} is already up to date!', + updated: '{name} has been updated.', + uninstalled: '{name} has been uninstalled.', + where_to_find: 'You can find your installed applications in your start menu.' + }, + modify: { + title: 'Choose an option:', + update: 'Update', + modify: 'Modify', + uninstall: 'Uninstall', + prompt: 'Are you sure you want to uninstall {name}?' + }, + back: 'Back', + exit: 'Exit', + yes: 'Yes', + no: 'No' + } +} diff --git a/ui/src/main.js b/ui/src/main.js index 70a71d0..ab0452b 100644 --- a/ui/src/main.js +++ b/ui/src/main.js @@ -3,14 +3,23 @@ import App from './App.vue' import router from './router' import axios from 'axios' import VueAxios from 'vue-axios' +import VueI18n from 'vue-i18n' import { stream_ajax as streamAjax } from './helpers' import Buefy from 'buefy' +import messages from './locales/messages.js' import 'buefy/dist/buefy.css' Vue.config.productionTip = false Vue.use(Buefy) +Vue.use(VueI18n) Vue.use(VueAxios, axios) +export const i18n = new VueI18n({ + locale: 'en', // set locale + fallbackLocale: 'en', + messages // set locale messages +}) + // Borrowed from http://tobyho.com/2012/07/27/taking-over-console-log/ function intercept (method) { console[method] = function () { @@ -76,7 +85,7 @@ window.addEventListener('keydown', disableShortcuts) axios.get('/api/attrs').then(function (resp) { document.getElementById('window-title').innerText = - resp.data.name + ' Installer' + i18n.t('app.window_title', { 'name': resp.data.name }) }).catch(function (err) { console.error(err) }) @@ -88,6 +97,7 @@ function selectFileCallback (name) { window.selectFileCallback = selectFileCallback var app = new Vue({ + i18n: i18n, router: router, data: { attrs: {}, @@ -115,13 +125,16 @@ var app = new Vue({ exit: function () { axios.get('/api/exit').catch(function (msg) { var searchLocation = app.metadata.install_path.length > 0 ? app.metadata.install_path - : 'the location where this installer is' + : i18n.t('error.location_unknown') app.$router.replace({ name: 'showerr', - params: { msg: msg + - '\n\nPlease upload the log file (in ' + searchLocation + ') to ' + - 'the ' + app.attrs.name + ' team' - } }) + params: { msg: i18n.t('error.exit_error', { + 'name': app.attrs.name, + 'path': searchLocation, + 'msg': msg + }) + } + }) }) }, stream_ajax: streamAjax diff --git a/ui/src/views/CompleteView.vue b/ui/src/views/CompleteView.vue index 4f7a463..88a044c 100644 --- a/ui/src/views/CompleteView.vue +++ b/ui/src/views/CompleteView.vue @@ -2,28 +2,28 @@
-

{{ $root.$data.attrs.name }} has been updated.

+

{{ $t('complete.updated', {'name': $root.$data.attrs.name}) }}

-

You can find your installed applications in your start menu.

+

{{ $t('complete.where_to_find') }}

-

{{ $root.$data.attrs.name }} is already up to date!

+

{{ $t('complete.up_to_date', {'name': $root.$data.attrs.name}) }}

-

You can find your installed applications in your start menu.

+

{{ $t('complete.where_to_find') }}

-

Thanks for installing {{ $root.$data.attrs.name }}!

+

{{ $t('complete.thanks', {'name': $root.$data.attrs.name}) }}

-

You can find your installed applications in your start menu.

+

{{ $t('complete.where_to_find') }}

-

{{ $root.$data.attrs.name }} has been uninstalled.

+

{{ $t('complete.uninstalled', {'name': $root.$data.attrs.name}) }}

- Exit + {{ $t('exit') }}

diff --git a/ui/src/views/DownloadConfig.vue b/ui/src/views/DownloadConfig.vue index 6e2d5b5..e90b37f 100644 --- a/ui/src/views/DownloadConfig.vue +++ b/ui/src/views/DownloadConfig.vue @@ -1,6 +1,6 @@