File tree Expand file tree Collapse file tree 18 files changed +404
-66
lines changed Expand file tree Collapse file tree 18 files changed +404
-66
lines changed Original file line number Diff line number Diff line change
1
+ import localeFr from "../../src/locales/fr" ;
2
+ import localeEn from "../../src/locales/en" ;
3
+ export default defineI18nConfig ( ( ) => ( {
4
+ legacy : false ,
5
+ locale : "fr" ,
6
+ messages : {
7
+ en : localeEn ,
8
+ fr : localeFr ,
9
+ } ,
10
+ } ) ) ;
Original file line number Diff line number Diff line change @@ -3,10 +3,13 @@ import svgLoader from "vite-svg-loader";
3
3
4
4
export default defineNuxtConfig ( {
5
5
srcDir : "src/" ,
6
- modules : [ "@pinia/nuxt" ] ,
6
+ modules : [ "@pinia/nuxt" , "@nuxtjs/i18n" ] ,
7
7
runtimeConfig : {
8
8
API_URL : process . env . API_URL || "" ,
9
9
} ,
10
+ i18n : {
11
+ vueI18n : "./modules_config/nuxt/i18n.config.ts" , // if you are using custom path, default
12
+ } ,
10
13
app : {
11
14
head : {
12
15
// @see https://getbootstrap.com/docs/5.0/getting-started/introduction/#starter-template
Original file line number Diff line number Diff line change 21
21
"vue-tsc" : " ^1.6.5"
22
22
},
23
23
"dependencies" : {
24
+ "@nuxtjs/i18n" : " ^8.0.0-rc.5" ,
24
25
"@pinia/nuxt" : " ^0.4.11" ,
25
26
"defu" : " ^6.1.2" ,
26
27
"h3" : " ^1.8.2" ,
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" grid" >
3
- <div class =" col-2 col-offset-8" >
4
- <NuxtLink to =" /auth/register" >Register</NuxtLink >
5
- </div >
3
+ <div class =" col-2 col-offset-8" ></div >
6
4
<div class =" col-2" >
7
- <p v-if =" username" >Welcome {{ username }}</p >
5
+ <p
6
+ v-if =" username"
7
+ v-t =" {
8
+ path: 'components.layout.appHeader.welcome',
9
+ args: { username },
10
+ }"
11
+ ></p >
8
12
</div >
9
13
</div >
10
14
</template >
Original file line number Diff line number Diff line change 2
2
<TieredMenu :model =" items" class =" h-screen sticky w-full" > </TieredMenu >
3
3
</template >
4
4
<script setup lang="ts">
5
+ const { t } = useI18n ();
5
6
const items = computed (() => [
6
7
{
7
- label: " Users " ,
8
+ label: t ( " components.layout.menu.appMenu.users " ) ,
8
9
icon: " pi pi-fw pi-file" ,
9
10
to: " /users" ,
10
11
},
11
12
{
12
- label: " Page1 " ,
13
+ label: t ( " components.layout.menu.appMenu.page1 " ) ,
13
14
icon: " pi pi-fw pi-pencil" ,
14
15
to: " /demo/page1" ,
15
16
},
16
17
{
17
- label: " Page2 " ,
18
+ label: t ( " components.layout.menu.appMenu.page2 " ) ,
18
19
icon: " pi pi-fw pi-pencil" ,
19
20
to: " /demo/page2" ,
20
21
},
21
22
{
22
- label: " Page3 " ,
23
+ label: t ( " components.layout.menu.appMenu.page3 " ) ,
23
24
icon: " pi pi-fw pi-pencil" ,
24
25
to: " /demo/page3" ,
25
26
},
26
27
{
27
28
separator: true ,
28
29
},
29
30
{
30
- label: " Quit " ,
31
+ label: t ( " components.layout.menu.appMenu.quit " ) ,
31
32
icon: " pi pi-fw pi-power-off" ,
32
33
},
33
34
]);
Original file line number Diff line number Diff line change 1
1
<template >
2
- <h1 >Register </h1 >
2
+ <h1 v-t = " { path: 'components.user.createForm.title' } " > </h1 >
3
3
<form @submit.prevent.stop =" registerUser" >
4
4
<UserForm
5
5
v-model:email =" email"
8
8
:is-password-confirmed =" isPasswordConfirmed"
9
9
/>
10
10
{{ errorMessage }}
11
- <button :disabled =" !securedPassword" >Register</button >
11
+ <button :disabled =" !isPasswordConfirmed" >
12
+ {{ $t("components.user.createForm.ok") }}
13
+ </button >
12
14
</form >
13
15
</template >
14
16
<script setup lang="ts">
@@ -25,10 +27,6 @@ const {
25
27
} = useUser ();
26
28
27
29
const registerUser = async () => {
28
- if (! securedPassword .value ) {
29
- // That mean you call this action without checking that data are OK. this shall not be executed
30
- throw createError (" You need a valid password" );
31
- }
32
30
try {
33
31
await createUser (email .value , securedPassword .value );
34
32
await navigateTo (" /users" );
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <label for =" email" >Email </label >
3
+ <label for =" email" >{{ $t("components.user.form.email") }} </label >
4
4
<input
5
5
type =" text"
6
6
:value =" email"
7
7
@input =" $emit('update:email', clearInput($event))"
8
8
/>
9
9
</div >
10
10
<div >
11
- <label for =" password" >Password </label >
11
+ <label for =" password" >{{ $t("components.user.form.password") }} </label >
12
12
<input
13
13
name =" password"
14
14
type =" password"
17
17
/>
18
18
</div >
19
19
<div >
20
- <label for =" passwordConfirm" >Confirm password</label >
20
+ <label for =" passwordConfirm" >{{
21
+ $t("components.user.form.passwordConfirm")
22
+ }}</label >
21
23
<input
22
24
name =" passwordConfirm"
23
25
type =" password"
24
26
:value =" passwordConfirm"
25
27
@input =" $emit('update:passwordConfirm', clearInput($event))"
26
28
/>
27
29
<span v-if =" !isPasswordConfirmed" class =" text-danger" >
28
- The confirm password is not the same as the password
30
+ {{ $t("components.user.form.errorPasswordConfirm") }}
29
31
</span >
30
32
</div >
31
33
</template >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div v-show =" userPending" >(Chargement)</div >
3
-
4
- <form v-if =" !userPending" @submit.prevent.stop =" updateUser" >
5
- <h1 >Update user {{ data.email }}</h1 >
2
+ <div
3
+ v-show =" userPending"
4
+ v-t =" { path: 'components.user.updateForm.pending' }"
5
+ ></div >
6
+ <form v-if =" data" @submit.prevent.stop =" updateUser" >
7
+ <h1 v-t =" { path: 'components.user.updateForm.title', args: data }" ></h1 >
6
8
<UserForm
7
9
v-model:email =" email"
8
10
v-model:password =" password"
11
13
/>
12
14
{{ errorMessage }}
13
15
{{ error }}
14
- <button type =" submit" >Save</button >
16
+ <Button type =" submit" :disabled =" !isPasswordConfirmed" >{{
17
+ $t("components.user.updateForm.ok")
18
+ }}</Button >
15
19
</form >
16
20
</template >
17
21
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import useAppFetch from "~/composables/useAppFetch";
4
4
5
5
export default async function useGetUser ( userId : string ) {
6
6
return useAppFetch < User > ( ( ) => "/users/" + userId , {
7
- key : "getUser" ,
7
+ key : "getUser" + userId ,
8
8
method : GET ,
9
9
} ) ;
10
10
}
Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ export default async function useListUsers() {
6
6
return useAppFetch < Array < User > > ( ( ) => "/users" , {
7
7
key : "listUsers" ,
8
8
method : GET ,
9
+ lazy : true ,
9
10
} ) ;
10
11
}
Original file line number Diff line number Diff line change @@ -3,19 +3,21 @@ import { User } from "~/types/User";
3
3
export default function useUser ( user : Ref < User > | undefined = undefined ) {
4
4
const password = ref ( "" ) ;
5
5
const passwordConfirm = ref ( "" ) ;
6
+ // This wont be kept in sync if user is modified! (to resolve)
6
7
const email = user ? toRef ( user ?. value ?. email ) : ref ( "" ) ;
7
8
const isPasswordConfirmed = computed (
8
9
( ) => password . value === passwordConfirm . value
9
10
) ;
10
11
11
12
const isPasswordEmpty = computed ( ( ) => ! password . value ) ;
13
+ const securedPassword = computed ( ( ) =>
14
+ isPasswordConfirmed && isPasswordEmpty ? password . value : ""
15
+ ) ;
12
16
return {
13
17
password,
14
18
passwordConfirm,
15
19
email : email ,
16
20
isPasswordConfirmed,
17
- securedPassword : computed ( ( ) =>
18
- isPasswordConfirmed && isPasswordEmpty ? password . value : ""
19
- ) ,
21
+ securedPassword,
20
22
} ;
21
23
}
Original file line number Diff line number Diff line change
1
+ export default {
2
+ components : {
3
+ user : {
4
+ createForm : {
5
+ title : "Create a new user" ,
6
+ ok : "Create" ,
7
+ } ,
8
+ updateForm : {
9
+ pending : "Loading user" ,
10
+ title : "Update {email}" ,
11
+ ok : "Update" ,
12
+ } ,
13
+ form : {
14
+ email : "Email" ,
15
+ password : "Password" ,
16
+ passwordConfirm : "Confirm your password" ,
17
+ errorPasswordConfirm : "The confirmation of the password is invalid" ,
18
+ } ,
19
+ } ,
20
+ layout : {
21
+ appHeader : {
22
+ welcome : "Welcome {username}" ,
23
+ } ,
24
+ menu : {
25
+ appMenu : {
26
+ users : "Users" ,
27
+ page1 : "page1" ,
28
+ page2 : "page2" ,
29
+ page3 : "page3" ,
30
+ quit : "Quit" ,
31
+ } ,
32
+ } ,
33
+ } ,
34
+ } ,
35
+ pages : {
36
+ page1 : {
37
+ altPanda : "This is to discover images" ,
38
+ background : "This is to discover background" ,
39
+ } ,
40
+ auth : {
41
+ login : {
42
+ username : "Email" ,
43
+ password : "Password" ,
44
+ title : "Please log-in" ,
45
+ ok : "Submit" ,
46
+ } ,
47
+ } ,
48
+ user : {
49
+ index : {
50
+ createButton : "New user" ,
51
+ pending : "Loading users" ,
52
+ title : "Users" ,
53
+ edit : "Edit" ,
54
+ delete : "Delete" ,
55
+ } ,
56
+ } ,
57
+ } ,
58
+ } ;
Original file line number Diff line number Diff line change
1
+ export default {
2
+ components : {
3
+ user : {
4
+ createForm : {
5
+ title : "Créer un nouvel utilisateur" ,
6
+ ok : "Créer" ,
7
+ } ,
8
+ updateForm : {
9
+ pending : "Chargement de l'utilisateur" ,
10
+ title : "Mise à jour de {email}" ,
11
+ ok : "Mettre à jour" ,
12
+ } ,
13
+ form : {
14
+ email : "Email" ,
15
+ password : "Mot de passe" ,
16
+ passwordConfirm : "Confirmez votre mot de passe" ,
17
+ errorPasswordConfirm : "La confirmation du mot de passe est invalide" ,
18
+ } ,
19
+ } ,
20
+ layout : {
21
+ appHeader : {
22
+ welcome : "Bienvenue {username}" ,
23
+ } ,
24
+ menu : {
25
+ appMenu : {
26
+ users : "Utilisateurs" ,
27
+ page1 : "page1" ,
28
+ page2 : "page2" ,
29
+ page3 : "page3" ,
30
+ quit : "Quitter" ,
31
+ } ,
32
+ } ,
33
+ } ,
34
+ } ,
35
+ pages : {
36
+ page1 : {
37
+ altPanda : "Découvrez les images" ,
38
+ background : "Découvrez les fonds d'écrans" ,
39
+ } ,
40
+ auth : {
41
+ login : {
42
+ username : "email" ,
43
+ password : "mot de passe" ,
44
+ title : "Connectez-vous" ,
45
+ ok : "Connexion" ,
46
+ } ,
47
+ } ,
48
+ user : {
49
+ index : {
50
+ createButton : "Créer un utilisateur" ,
51
+ pending : "Chargement des utilisateurs" ,
52
+ title : "Utilisateurs" ,
53
+ edit : "Editer" ,
54
+ delete : "Supprimer" ,
55
+ } ,
56
+ } ,
57
+ } ,
58
+ } ;
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div >
3
- <div >
4
- <h1 >Welcome to the login page</h1 >
5
- <form @submit.prevent.stop =" submitAuthenticateUser" >
6
- <div >
7
- <label for =" email" >Email</label >
8
- <input v-model =" username" name =" email" type =" text" />
2
+ <main id =" main" class =" main" >
3
+ <section class =" login flex-nowrap" >
4
+ <div class =" welcome-box" >
5
+ <div class =" content-box no-padding" >
6
+ <h1 >{{ $t("pages.auth.login.title") }}</h1 >
9
7
</div >
10
- <div >
11
- <label for =" password" >Password</label >
12
- <input v-model =" password" name =" password" type =" password" />
13
- </div >
14
- <button type =" submit" >Log-in</button >
8
+ </div >
9
+ <form
10
+ class =" login-form temporary-primary-bg"
11
+ @submit.prevent.stop =" submitAuthenticateUser"
12
+ >
13
+ <InputText
14
+ v-model =" username"
15
+ type =" text"
16
+ :placeholder =" $t('pages.auth.login.username')"
17
+ />
18
+ <InputText
19
+ v-model =" password"
20
+ type =" password"
21
+ :placeholder =" $t('pages.auth.login.password')"
22
+ />
23
+
24
+ <Button type =" submit" > {{ $t("pages.auth.login.ok") }}</Button >
15
25
<div v-if =" errorMessage" >{{ errorMessage }}</div >
16
26
</form >
17
- </div >
18
- </div >
27
+ </section >
28
+ </main >
19
29
</template >
20
30
<script setup lang="ts">
21
31
import { ref } from " vue" ;
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
3
Page 1
4
- <img src =" ~/assets/images/panda.webp" alt =" Discover Pandas " />
5
- <div class =" panda-background" >This is to discover background scss </div >
4
+ <img src =" ~/assets/images/panda.webp" : alt =" $t('pages.page1.altPanda') " />
5
+ <div class =" panda-background" >{{ $t("pages.page1. background") }} </div >
6
6
</div >
7
7
</template >
8
8
<script lang="ts" setup>
You can’t perform that action at this time.
0 commit comments