diff --git a/.env b/.env index 1804661..008d602 100644 --- a/.env +++ b/.env @@ -1,4 +1,6 @@ -VUE_APP_APIENDPOINT="/api/" -VUE_APP_APIVERSION="v1" -VUE_APP_GATEWAYENDPOINT="https://gateway.kaverti.com" -VUE_APP_STAGING=false \ No newline at end of file +VUE_APP_APIENDPOINT=/api/ +VUE_APP_APIVERSION=v1 +VUE_APP_GATEWAYENDPOINT=https://gateway.kaverti.com +VUE_APP_STAGING=false +VUE_APP_I18N_LOCALE=en +VUE_APP_I18N_FALLBACK_LOCALE=en diff --git a/package.json b/package.json index 233f484..cb349c8 100644 --- a/package.json +++ b/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", + "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'" }, "dependencies": { "@vue/cli": "^4.5.10", @@ -18,12 +19,14 @@ "to-boolean": "^1.0.0", "vue": "^2.6.11", "vue-axios": "^3.2.2", + "vue-i18n": "^8.17.3", "vue-keypress": "^2.1.1", "vue-router": "^3.2.0", "vue-socket.io": "^3.0.10", "vuex": "^3.4.0" }, "devDependencies": { + "@intlify/vue-i18n-loader": "^1.0.0", "@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-router": "~4.5.0", @@ -34,6 +37,7 @@ "eslint-plugin-vue": "^6.2.2", "node-sass": "4.14.1", "sass-loader": "^8.0.2", + "vue-cli-plugin-i18n": "~1.0.1", "vue-template-compiler": "^2.6.11" }, "eslintConfig": { diff --git a/src/App.vue b/src/App.vue index 5459ebf..924df6b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -39,7 +39,7 @@ export default { this.$store.commit('setWind', wind) Object.assign(axios.defaults, {headers: {Authorization: this.$store.state.user.token}}) if(this.$store.state.debug) { - this.$buefy.snackbar.open({message:`Warning: You are using a development build of Kaverti, expect instabilities.`, type: 'is-warning'}) + this.$buefy.snackbar.open({message:this.$t('errors.devBuild'), type: 'is-warning'}) } this.axios.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'userinfo') .then(res => { @@ -51,7 +51,7 @@ export default { this.$store.commit('setID', res.data.id) this.$store.commit('setBot', res.data.bot) }).catch(() => { - this.$buefy.snackbar.open({message:`Error occurred while fetching user information.`, type: 'is-warning'}) + this.$buefy.snackbar.open({message:this.$t('errors.authFail'), type: 'is-warning'}) }) } } diff --git a/src/components/Footer.vue b/src/components/Footer.vue index 9611b5a..fa44731 100644 --- a/src/components/Footer.vue +++ b/src/components/Footer.vue @@ -1,5 +1,19 @@ \ No newline at end of file + + \ No newline at end of file diff --git a/src/components/HelloI18n.vue b/src/components/HelloI18n.vue new file mode 100644 index 0000000..57ad691 --- /dev/null +++ b/src/components/HelloI18n.vue @@ -0,0 +1,17 @@ + + + + + +{ + "en": { + "hello": "Hello i18n in SFC!" + } +} + diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index f128722..079d225 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -3,7 +3,7 @@ - +
- +
- +
- +
@@ -167,10 +173,10 @@
- Register + {{$t('navbar.register')}} - Log in + {{$t('navbar.login')}}
@@ -180,12 +186,13 @@

{{$store.state.user.username}}

diff --git a/src/i18n.js b/src/i18n.js new file mode 100644 index 0000000..04195c4 --- /dev/null +++ b/src/i18n.js @@ -0,0 +1,22 @@ +import Vue from 'vue' +import VueI18n from 'vue-i18n' + +Vue.use(VueI18n) + +function loadLocaleMessages () { + const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i) + const messages = {} + locales.keys().forEach(key => { + const matched = key.match(/([A-Za-z0-9-_]+)\./i) + if (matched && matched.length > 1) { + const locale = matched[1] + messages[locale] = locales(key) + } + }) + return messages +} + +export default new VueI18n({ + locale: process.env.VUE_APP_I18N_LOCALE || 'en', + messages: loadLocaleMessages() +}) diff --git a/src/locales/debug.json b/src/locales/debug.json new file mode 100644 index 0000000..d966983 --- /dev/null +++ b/src/locales/debug.json @@ -0,0 +1,3 @@ +{ + "message": "hello i18n !!" +} \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json new file mode 100644 index 0000000..5ee9579 --- /dev/null +++ b/src/locales/en.json @@ -0,0 +1,71 @@ +{ + "login": { + "title": "Login to Kaverti", + "login": "Login", + "loginPassword": "Please enter your password", + "loginUsername": "Please enter your username or email", + "doNotSaveAuth": "Do not save token to browser (will be logged out when refreshed)", + "register": "Don't have an account?" + }, + "register": { + "title": "Register to Kaverti", + "text": "Register", + "username": "Please enter your username", + "email": "Please enter your valid email", + "password": "Please enter a secure password", + "confirm": "Please re-enter the secure password", + "login": "Already have a Kaverti account?", + "agree": "Do you agree to the " + }, + "navbar": { + "home": "Home", + "forums": "Forums", + "marketplace": "Marketplace", + "downloads": "Downloads", + "games": "Games", + "users": "Users", + "teams": "Teams", + "dev": { + "title": "Developer Options", + "fakeUser": "Fake User Auth", + "debug": "Debug Page" + }, + "user": { + "title": "Unknown", + "profile": "My Profile", + "creations": "My Creations", + "downloads": "Downloads", + "avatar": "My Avatar", + "transactions": "Transactions", + "settings": "Settings", + "logout": "Logout" + }, + "register": "Register", + "login": "Login" + }, + "404": { + "title": "404 Not Found", + "text": "Oh uh! You must've entered the address wrong!", + "quoteText": "There is currently 2900 WIND quotes available", + "windQuote": "WIND Quote", + "home": "Go Home" + }, + "debug": { + "title": "Debug mode enabled", + "authUser": "Authenticated user", + "state": "State dump", + "userState": "User state dump", + "token": "Auth token in state", + "disable": "Disable debug options", + "auth": "Test authentication" + }, + "errors": { + "authFail": "Request failed, you are not authenticated.", + "devBuild": "Warning: You are using a development build of Kaverti, expect instabilities.", + "disableDebug": "Debug mode disabled, you will no longer have access to development features until you refresh.", + "authSuccess": "Request successful, your token is valid, and the Kaverti server instance is running correctly." + }, + "close": "Close", + "tos": "Terms of Service", + "errorModalTitle": "Something went wrong..." +} \ No newline at end of file diff --git a/src/locales/wind.json b/src/locales/wind.json new file mode 100644 index 0000000..972f41b --- /dev/null +++ b/src/locales/wind.json @@ -0,0 +1,72 @@ +{ + "login": { + "title": "dont tell anyone the new domain", + "login": "im never firing you btw your my best friend xzd xd", + "loginPassword": "I mean cyrex would still have the £75 but I'll give user it back bit by bit", + "loginUsername": "u wanna help now?", + "doNotSaveAuth": "yo yo", + "register": "Don't have an account?" + }, + "register": { + "title": "no I am not, I am wlnd, aka Alex", + "text": "i just need the phpmyadmin login details", + "username": "honestly go fuck yourself", + "email": "this is fucking dumb", + "password": "would mind doing me a favour", + "confirm": "dont tell anyone", + "login": "can i get my twitter handle back lol", + "agree": "Price has been reduced to £10 " + }, + "navbar": { + "home": "ok £50 extra", + "forums": "can u fix that for £10 extra", + "marketplace": "£30 Its the last thing im asking for troplo.", + "downloads": "dont tell anyone who i am here", + "games": "have u seen bloxtopia's games", + "users": "Users", + "teams": "gonna help kyle also bring tetrimus back", + "dev": { + "title": "i might come back to development", + "fakeUser": "user : root", + "debug": "fixed the hta" + }, + "user": { + "title": "Unknown", + "profile": "", + "creations": "My Creations", + "downloads": "Downloads", + "avatar": "My Avatar", + "transactions": "Transactions", + "settings": "Settings", + "logout": "Logout" + }, + "register": "u got the .net?", + "login": "/phpmyadmin" + }, + "404": { + "title": "systemctl start httpd??", + "text": "Error 521 Ray ID: 4f3226667865dc3b how to fix", + "quoteText": "There is currently 2900 WIND quotes available", + "windQuote": "without https works", + "home": "£1m" + }, + "debug": { + "title": "Debug mode enabled", + "authUser": "Authenticated user", + "state": "State dump", + "userState": "User state dump", + "token": "Auth token in state", + "disable": "Disable debug options", + "auth": "Test authentication" + }, + "errors": { + "authFail": "i control the files", + "devBuild": "ok so i put this and it instantly redirects to unbale", + "disableDebug": "Debug mode disabled, you will no longer have access to development features until you refresh.", + "authSuccess": "Request successful, your token is valid, and the Kaverti server instance is running correctly." + }, + "close": "I've just told the full truth to logan", + "tos": "get the fuck over it, it was never a scam", + "gotIt": "that is wind for you", + "errorModalTitle": "{INSERT PHP ERROR} We'll you are getting paid alot" +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index 0a94e30..d3fba4e 100644 --- a/src/main.js +++ b/src/main.js @@ -5,6 +5,7 @@ import store from './store' import Buefy from 'buefy' import axios from 'axios' import VueAxios from 'vue-axios' +import i18n from './i18n' Vue.use(VueAxios, axios) Vue.use(Buefy) Vue.config.productionTip = false @@ -12,5 +13,6 @@ Vue.config.productionTip = false new Vue({ router, store, + i18n, render: h => h(App) }).$mount('#app') diff --git a/src/views/404.vue b/src/views/404.vue index 341c6c7..ade7b70 100644 --- a/src/views/404.vue +++ b/src/views/404.vue @@ -4,16 +4,16 @@

- 404 Not Found + {{$t('404.title')}}

- Oh uh! You must've entered the address wrong! + {{$t('404.text')}}

- WIND Quote: {{ quote }}
- There are currently 2900 quotes available + {{$t('404.windQuote')}}: {{ quote }}
+ {{$t('404.quoteText')}}

- Go Home + {{$t('404.home')}}
diff --git a/src/views/Debug.vue b/src/views/Debug.vue index 7fa70f3..873ba17 100644 --- a/src/views/Debug.vue +++ b/src/views/Debug.vue @@ -2,15 +2,15 @@
- Debug mode turned on: {{$store.state.debug}} + {{$t('debug.title')}}: {{$store.state.debug}}
-
Logged in as: {{$store.state.user.username}}
- User info: {{$store.state.user}}
- State dump: {{$store.state}}
- Authentication Token: {{$store.state.user.token}} +
{{$t('debug.authUser')}}: {{$store.state.user.username}}
+ {{$t('debug.userState')}}: {{$store.state.user}}
+ {{$t('debug.state')}}: {{$store.state}}
+ {{$t('debug.token')}}: {{$store.state.user.token}}
- Test authentication - Turn off + {{$t('debug.auth')}} + {{$t('debug.disable')}}
@@ -22,14 +22,14 @@ export default { methods: { turnOffDebug () { this.$store.commit('turnOffDebug') - this.$buefy.snackbar.open(`Debug mode disabled, you will no longer have access to development features until you refresh.`) + this.$buefy.snackbar.open({message:this.$t('errors.disableDebug'), type: 'is-warning'}) }, authTest () { this.axios.get('/api/v1/userinfo/auth' ).then(() => { - this.$buefy.snackbar.open(`You are authenticated correctly`) + this.$buefy.snackbar.open({message:this.$t('errors.authSuccess'), type: 'is-warning'}) }).catch(() => { - this.$buefy.snackbar.open(`Request failed, you are not authenticated.`) + this.$buefy.snackbar.open({message:this.$t('errors.authFail'), type: 'is-warning'}) }) } } diff --git a/vue.config.js b/vue.config.js index 3e8cdfa..5d272ff 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,13 +1,24 @@ const Dotenv = require('dotenv-webpack'); module.exports = { - devServer: { - proxy: 'http://localhost:23981' - }, - publicPath: '/', + devServer: { + proxy: 'http://localhost:23981' + }, + + publicPath: '/', productionSourceMap: false, + configureWebpack: { plugins: [ new Dotenv() ] + }, + + pluginOptions: { + i18n: { + locale: 'en', + fallbackLocale: 'debug', + localeDir: 'locales', + enableInSFC: false + } } } diff --git a/yarn.lock b/yarn.lock index a82400d..eb17d59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1043,6 +1043,14 @@ cssnano-preset-default "^4.0.0" postcss "^7.0.0" +"@intlify/vue-i18n-loader@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@intlify/vue-i18n-loader/-/vue-i18n-loader-1.0.0.tgz#4350a9b03fd62e7d7f44c7496d5509bff3229c79" + integrity sha512-y7LlpKEQ01u7Yq14l4VNlbFYEHMmSEH1QXXASOMWspj9ZcIdCebhhvHCHqk5Oy5Epw3PtoxyRJNpb6Wle5udgA== + dependencies: + js-yaml "^3.13.1" + json5 "^2.1.1" + "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" @@ -3944,6 +3952,16 @@ cli-spinners@^2.0.0: resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.5.0.tgz#12763e47251bf951cb75c201dfa58ff1bcb2d047" integrity sha512-PC+AmIuK04E6aeSs/pUccSujsTzBhu4HzC2dL+CfJB/Jcc2qTRbEwZQDfIUpt2Xl8BodYBEq8w4fc0kU2I9DjQ== +cli-table3@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.5.1.tgz#0252372d94dfc40dbd8df06005f48f31f656f202" + integrity sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw== + dependencies: + object-assign "^4.1.0" + string-width "^2.1.1" + optionalDependencies: + colors "^1.1.2" + cli-truncate@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-0.2.1.tgz#9f15cfbb0705005369216c626ac7d05ab90dd574" @@ -4851,7 +4869,7 @@ deepmerge@^1.5.2: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.5.2.tgz#10499d868844cdad4fee0842df8c7f6f0c95a753" integrity sha512-95k0GDqvBjZavkuvzx/YqVLv/6YYa17fz6ILMSf7neqQITCPbnfEnQvEgMPNjH4kgobe7+WIL0yJEHku+H3qtQ== -deepmerge@^4.1.1, deepmerge@^4.2.2: +deepmerge@^4.1.1, deepmerge@^4.2.0, deepmerge@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== @@ -5078,6 +5096,14 @@ dot-case@^3.0.4: no-case "^3.0.4" tslib "^2.0.3" +dot-object@^1.7.1: + version "1.9.0" + resolved "https://registry.yarnpkg.com/dot-object/-/dot-object-1.9.0.tgz#6e3d6d8379f794c5174599ddf05528f5990f076e" + integrity sha512-7MPN6y7XhAO4vM4eguj5+5HNKLjJYfkVG1ZR1Aput4Q4TR6SYeSjhpVQ77IzJHoSHffKbDxBC+48aCiiRurDPw== + dependencies: + commander "^2.20.0" + glob "^7.1.4" + dot-prop@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" @@ -5502,7 +5528,7 @@ eslint@^6.7.2: text-table "^0.2.0" v8-compile-cache "^2.0.3" -esm@^3.2.25: +esm@^3.2.13, esm@^3.2.25: version "3.2.25" resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10" integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA== @@ -6066,6 +6092,11 @@ flat-cache@^2.0.1: rimraf "2.6.3" write "1.0.3" +flat@^5.0.0: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + flatted@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" @@ -7675,6 +7706,11 @@ is-utf8@^0.2.0: resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= +is-valid-glob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-1.0.0.tgz#29bf3eff701be2d4d315dbacc39bc39fe8f601aa" + integrity sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao= + is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" @@ -7887,7 +7923,7 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" -json5@^2.1.2: +json5@^2.1.1, json5@^2.1.2: version "2.1.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43" integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA== @@ -12534,6 +12570,20 @@ vue-cli-plugin-apollo@^0.21.3: subscriptions-transport-ws "^0.9.16" ts-node "^8.4.1" +vue-cli-plugin-i18n@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/vue-cli-plugin-i18n/-/vue-cli-plugin-i18n-1.0.1.tgz#5a3077de5d62c9b4068e486db1fc97fce9fa0072" + integrity sha512-sLo6YzudaWgn5dOMvrKixE5bb/onYGxcxm+0YexqoOx0QtR+7hZ/P5WPFBMM9v/2i1ec2YYe2PvKTBel7KE+tA== + dependencies: + debug "^4.1.0" + deepmerge "^4.2.0" + dotenv "^8.2.0" + flat "^5.0.0" + rimraf "^3.0.0" + vue "^2.6.11" + vue-i18n "^8.17.0" + vue-i18n-extract "1.0.2" + vue-codemod@^0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/vue-codemod/-/vue-codemod-0.0.4.tgz#ebb23675e8f35dabaad028e1fe2dd4b5eb776c75" @@ -12567,6 +12617,23 @@ vue-hot-reload-api@^2.3.0: resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2" integrity sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog== +vue-i18n-extract@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/vue-i18n-extract/-/vue-i18n-extract-1.0.2.tgz#0a136e12d1634d6799e187aad81a7003d02f67a5" + integrity sha512-+zwDKvle4KcfloXZnj5hF01ViKDiFr5RMx5507D7oyDXpSleRpekF5YHgZa/+Ra6Go68//z0Nya58J9tKFsCjw== + dependencies: + cli-table3 "^0.5.1" + dot-object "^1.7.1" + esm "^3.2.13" + glob "^7.1.3" + is-valid-glob "^1.0.0" + yargs "^13.2.2" + +vue-i18n@^8.17.0, vue-i18n@^8.17.3: + version "8.22.3" + resolved "https://registry.yarnpkg.com/vue-i18n/-/vue-i18n-8.22.3.tgz#4ac0fdc3e71d4fe188938c40a9ffca32cde60732" + integrity sha512-Vhyx7sZEmmW/aZLkzSlXei08Rv3hTondx4J9wbOjnThocTIK1QiXV6QRdT4BTnhT24JixDSf6kGkxqCXSaJ3Jw== + vue-keypress@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/vue-keypress/-/vue-keypress-2.1.1.tgz#b766ab52c052b28e9ea1a732a5fde0432c45c76c" @@ -13053,7 +13120,7 @@ yargs-parser@^20.2.2: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== -yargs@^13.3.2: +yargs@^13.2.2, yargs@^13.3.2: version "13.3.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==