diff --git a/server/controllers/auth.go b/server/controllers/auth.go index c53af83..a80b1b8 100644 --- a/server/controllers/auth.go +++ b/server/controllers/auth.go @@ -115,7 +115,7 @@ func userLogin(c *gin.Context) { Email: user.Email, Token: token, RefreshToken: refreshToken, - Role: user.RoleDetail().Long, + Role: user.RoleDetail().Key, } c.JSON(http.StatusOK, response) } @@ -149,7 +149,7 @@ func refresh(c *gin.Context) { Email: user.Email, Token: token, RefreshToken: refreshToken, - Role: user.RoleDetail().Long, + Role: user.RoleDetail().Key, } c.JSON(http.StatusOK, response) } else { diff --git a/server/db/enums.go b/server/db/enums.go index 296d06e..6956762 100644 --- a/server/db/enums.go +++ b/server/db/enums.go @@ -52,75 +52,58 @@ const ( ) type EnumDetail struct { - Short string `json:"short"` - Long string `json:"long"` + Key string `json:"key"` } var FuelUnitDetails map[FuelUnit]EnumDetail = map[FuelUnit]EnumDetail{ LITRE: { - Short: "Lt", - Long: "Litre", + Key: "litre", }, GALLON: { - Short: "Gal", - Long: "Gallon", + Key: "gallon", }, KILOGRAM: { - Short: "Kg", - Long: "Kilogram", + Key: "kilogram", }, KILOWATT_HOUR: { - Short: "KwH", - Long: "Kilowatt Hour", + Key: "kilowatthour", }, US_GALLON: { - Short: "US Gal", - Long: "US Gallon", + Key: "usgallon", }, MINUTE: { - Short: "Mins", - Long: "Minutes", + Key: "minutes", }, } var FuelTypeDetails map[FuelType]EnumDetail = map[FuelType]EnumDetail{ PETROL: { - Short: "Petrol", - Long: "Petrol", + Key: "petrol", }, DIESEL: { - Short: "Diesel", - Long: "Diesel", + Key: "diesel", }, CNG: { - Short: "CNG", - Long: "CNG", + Key: "cng", }, LPG: { - Short: "LPG", - Long: "LPG", + Key: "lpg", }, ELECTRIC: { - Short: "Electric", - Long: "Electric", + Key: "electric", }, ETHANOL: { - Short: "Ethanol", - Long: "Ethanol", + Key: "ethanol", }, } var DistanceUnitDetails map[DistanceUnit]EnumDetail = map[DistanceUnit]EnumDetail{ KILOMETERS: { - Short: "Km", - Long: "Kilometers", + Key: "kilometers", }, MILES: { - Short: "Mi", - Long: "Miles", + Key: "miles", }, } var RoleDetails map[Role]EnumDetail = map[Role]EnumDetail{ ADMIN: { - Short: "Admin", - Long: "ADMIN", + Key: "ADMIN", }, USER: { - Short: "User", - Long: "USER", + Key: "USER", }, } diff --git a/ui/package.json b/ui/package.json index bf6c486..9911b0d 100644 --- a/ui/package.json +++ b/ui/package.json @@ -41,10 +41,12 @@ "currency-formatter": "^1.5.7", "date-fns": "2.10.0", "lodash": "^4.17.21", + "node-gyp": "^9.3.1", "normalize.css": "8.0.1", "nprogress": "0.2.0", "vue": "2.6.11", "vue-chartjs": "^3.5.1", + "vue-i18n": "^8.28.2", "vue-meta": "2.3.3", "vue-router": "3.1.6", "vuex": "3.1.2" diff --git a/ui/src/components/createQuickEntry.vue b/ui/src/components/createQuickEntry.vue index fe8dc72..d535ebc 100644 --- a/ui/src/components/createQuickEntry.vue +++ b/ui/src/components/createQuickEntry.vue @@ -20,7 +20,7 @@ export default { } } else { if (this.file == null) { - return 'Upload Photo' + return this.$t('uploadphoto') } else { return '' } @@ -39,7 +39,7 @@ export default { .post(`/api/quickEntries`, formData) .then((data) => { this.$buefy.toast.open({ - message: 'Quick Entry Created Successfully', + message: this.$t('quickentrycreatedsuccessfully'), type: 'is-success', duration: 3000, }) @@ -68,9 +68,9 @@ export default {
-

Quick Entry

+

{{ $tc('quickentry',1) }}

Take a pic of the invoice or the fuel pump display to make an entry later.

{{ $t('quickentrydesc') }}

@@ -99,10 +99,10 @@ export default { native-type="submit" :disabled="tryingToCreate" type="is-primary" - value="Upload File" + :value="this.$t('uploadfile')" class="control" > - Upload File + {{ $t('uploadfile') }}
diff --git a/ui/src/components/mileageChart.vue b/ui/src/components/mileageChart.vue index a917529..f6fea40 100644 --- a/ui/src/components/mileageChart.vue +++ b/ui/src/components/mileageChart.vue @@ -30,7 +30,7 @@ export default { var labels = this.chartData.map((x) => x.date.substr(0, 10)) var dataset = { steppedLine: true, - label: `Mileage (${this.user.distanceUnitDetail.short}/${this.vehicle.fuelUnitDetail.short})`, + label: `${this.$t('odometer')} (${this.$t('unit.short.' + this.user.distanceUnitDetail.key)}/${this.$t('unit.short.' + this.vehicle.fuelUnitDetail.key)})`, fill: true, data: this.chartData.map((x) => x.mileage), } diff --git a/ui/src/components/nav-bar.vue b/ui/src/components/nav-bar.vue index fbac02b..d2a7784 100644 --- a/ui/src/components/nav-bar.vue +++ b/ui/src/components/nav-bar.vue @@ -10,42 +10,42 @@ export default { persistentNavRoutes: [ { name: 'home', - title: 'Home', + title: this.$t('menu.home'), }, ], loggedInNavRoutes: [ { name: 'quickEntries', - title: () => 'Quick Entries', + title: () => this.$t('menu.quickentries'), badge: () => this.unprocessedQuickEntries.length, }, { name: 'import', - title: () => 'Import', + title: () => this.$t('menu.import'), }, { name: 'settings', - title: 'Settings', + title: this.$t('menu.settings'), }, { name: 'logout', - title: 'Log out', + title: this.$t('menu.logout'), }, ], loggedOutNavRoutes: [ { name: 'login', - title: 'Log in', + title: this.$t('menu.login'), }, ], adminNavRoutes: [ { name: 'site-settings', - title: 'Site Settings', + title: this.$t('menu.sitesettings'), }, { name: 'users', - title: 'Users', + title: this.$t('menu.users'), }, ], } @@ -72,7 +72,7 @@ export default { - + diff --git a/ui/src/components/quickEntryDisplay.vue b/ui/src/components/quickEntryDisplay.vue index 602d844..0381302 100644 --- a/ui/src/components/quickEntryDisplay.vue +++ b/ui/src/components/quickEntryDisplay.vue @@ -50,12 +50,12 @@ export default {

diff --git a/ui/src/components/shareVehicle.vue b/ui/src/components/shareVehicle.vue index d324b50..35ed5b1 100644 --- a/ui/src/components/shareVehicle.vue +++ b/ui/src/components/shareVehicle.vue @@ -55,7 +55,7 @@ export default { return } this.$buefy.dialog.confirm({ - title: 'Transfer Vehicle', + title: this.$t('transfervehicle'), message: 'Are you sure you want to do this? You will lose ownership and all editing rights if you confirm.', cancelText: 'Cancel', confirmText: 'Go Ahead', @@ -90,7 +90,7 @@ export default {