Added multilanguage for authors

This commit is contained in:
konrad 2017-11-22 15:13:33 +01:00 committed by kolaente
parent 6d14c7ba72
commit b406777a1f
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 45 additions and 40 deletions

View File

@ -4,13 +4,11 @@
<div class="ui info message" v-if="loading">
<icon name="refresh" spin></icon>&nbsp;&nbsp;
Loading...
<span v-lang.general.loading></span>
</div>
<div class="ui negative message" v-if="error">
<div class="header">
An error occured.
</div>
<div class="header" v-lang.general.error></div>
{{ error.message }}
<p v-if="error.response.data">
{{ error.response.data.Message }}
@ -21,20 +19,16 @@
<router-link :to="{ name: 'author-edit', params: { id: authorID} }" class="ui teal labeled icon button" style="float: right;">
<i class="edit icon"></i>
Edit
<span v-lang.general.edit></span>
</router-link>
<div class="ui list">
<div class="item">
<div class="header">
Forename
</div>
<div class="header" v-lang.authors.forename></div>
{{ author.Forename }}
</div>
<div class="item">
<div class="header">
Lastname
</div>
<div class="header" v-lang.authors.lastname></div>
{{ author.Lastname }}
</div>
</div>

View File

@ -1,16 +1,14 @@
<template>
<div v-if="user.authenticated">
<h1>Authors overview</h1>
<h1 v-lang.authors.title></h1>
<div class="ui info message" v-if="loading">
<icon name="refresh" spin></icon>&nbsp;&nbsp;
Loading...
<span v-lang.general.loading></span>
</div>
<div class="ui negative message" v-if="error">
<div class="header">
An error occured.
</div>
<div class="header" v-lang.genral.error></div>
{{ error.message }}
<p v-if="error.response.data">
{{ error.response.data.Message }}
@ -18,9 +16,7 @@
</div>
<div class="ui positive message" v-if="success">
<div class="header">
Success
</div>
<div class="header" v-lang.general.success></div>
{{ success }}
</div>
@ -28,17 +24,17 @@
<router-link to="/authors/add" class="ui green labeled icon button" style="float: right;">
<i class="plus icon"></i>
Add a new author
<span v-lang.authors.newAuthor></span>
</router-link>
<button @click="loadAuthors()" class="ui teal labeled icon button" style="float: right;">
<i class="refresh icon"></i>
Refresh
<span v-lang.general.refresh></span>
</button>
<form id="search">
<div class="ui icon input">
<input placeholder="Search for anything..." type="text" v-model="searchQuery" v-focus>
<input :placeholder="langGeneral.search" type="text" v-model="searchQuery" v-focus>
<i class="search icon"></i>
</div>
</form>
@ -68,8 +64,7 @@
}"
>
</paginate-links>
<div v-if="$refs.paginator">
Viewing {{$refs.paginator.pageItemsCount}} results
<div v-if="$refs.paginator" v-lang.general.searchResultCount="$refs.paginator.pageItemsCount">
</div>
</div>
</div>
@ -77,8 +72,8 @@
v-if="showModal"
@close="showModal = false"
v-on:submit="deleteBtnSuccess()">
<span slot="header">Delete this author</span>
<p slot="text">Are you sure you want to delete this author? This cannot be undone!</p>
<span slot="header" v-lang.authors.deleteHeader></span>
<p slot="text" v-lang.authors.deleteMsg></p>
</modal>
</div>
</template>
@ -95,7 +90,7 @@ export default {
user: auth.user,
authors: [],
searchQuery: '',
gridColumns: ['Name'],
gridColumns: [],
gridButtons: [
{
text: 'Delete',
@ -120,6 +115,9 @@ export default {
},
created () {
this.loadAuthors()
this.gridButtons[0].text = this.translate('general').delete
this.gridColumns = [this.translate('general').name]
},
watch: {
// call again the method if the route changes
@ -141,6 +139,9 @@ export default {
})
}
return data
},
langGeneral () {
return this.translate('general')
}
},
methods: {
@ -182,7 +183,7 @@ export default {
.then(response => {
console.log(response)
if (response.status === 200 && response.data.Message === 'success') {
this.success = 'The author was deleted successfully.'
this.success = this.translate('authors').deleteSuccess
this.loadAuthors()
}
})

View File

@ -1,9 +1,7 @@
<template>
<div>
<div class="ui negative message" v-if="error">
<div class="header">
An error occured.
</div>
<div class="header" v-lang.general.error></div>
{{ error.message }}
<template v-if="error.response">
<br/>{{ error.response.data.Message }}
@ -11,24 +9,22 @@
</div>
<div class="ui positive message" v-if="success">
<div class="header">
Success
</div>
<div class="header" v-lang.general.success></div>
{{ success }}
</div>
<form class="ui form" v-bind:class="{ loading: loading }" v-if="!success" @submit.prevent="insertOrUpdateAuthor">
<div class="field">
<label>Forename</label>
<input name="forename" placeholder="Forename" type="text" v-model="author.Forename" v-focus>
<label v-lang.authors.forename></label>
<input name="forename" :placeholder="langAuthors.forename" type="text" v-model="author.Forename" v-focus>
</div>
<div class="field">
<label>Lastname</label>
<input name="lastname" placeholder="Lastname" type="text" v-model="author.Lastname" required>
<label v-lang.authors.lastname></label>
<input name="lastname" :placeholder="langAuthors.lastname" type="text" v-model="author.Lastname" required>
</div>
<button class="ui blue button" type="submit">Submit</button>
<button class="ui blue button" type="submit" v-lang.general.submit></button>
</form>
</div>
</template>
@ -67,6 +63,11 @@
}
this.loading = false
},
computed: {
langAuthors () {
return this.translate('authors')
}
},
methods: {
insertOrUpdateAuthor: function () {
if (this.author.Lastname === '') {

View File

@ -36,7 +36,7 @@ export default {
publishers: 'Publishers'
},
books: {
title: 'Books Overview',
title: 'Books overview',
add: 'Add a book',
deleteHeader: 'Delete this book',
deleteMsg: 'Are you sure you want to delete this book? <b>This cannot be undone!</b>',
@ -53,5 +53,14 @@ export default {
},
newPublisher: 'Add new publisher',
newAuthor: 'Add new author'
},
authors: {
title: 'Authors overview',
newAuthor: 'Add new author',
deleteHeader: 'Delete this author',
deleteMsg: 'Are you sure you want to delete this author? <b>This cannot be undone!</b>',
deleteSuccess: 'The author was deleted successfully.',
forename: 'Forename',
lastname: 'Lastname'
}
}