ソースを参照

feat: :sparkles: feat (traducoes) adicionada opção de troca de linguagem no perfil

foi adicionada a opcao de troca de linguagem do sistema no perfil do cadastro

fase:dev | origin:escopo
Gustavo Zanatta 2 週間 前
コミット
3769fb2576

+ 10 - 0
src/i18n/locales/en.json

@@ -322,6 +322,10 @@
     "placeholder_name": "Enter your name",
     "placeholder_email": "Enter your e-mail",
     "placeholder_phone": "Enter your phone",
+    "language": "Language",
+    "lang_pt": "PT-br",
+    "lang_en": "EN-us",
+    "lang_es": "ES-es",
     "bank_data": {
       "title": "Bank data",
       "description": "Pix, agency and account",
@@ -654,5 +658,11 @@
       "home": "Residential",
       "commercial": "Commercial"
     }
+  },
+  "nav": {
+    "home": "Home",
+    "payments": "Payments",
+    "agenda": "Schedule",
+    "profile": "Profile"
   }
 }

+ 10 - 0
src/i18n/locales/es.json

@@ -322,6 +322,10 @@
     "placeholder_name": "Escriba su nombre",
     "placeholder_email": "Escriba su correo electrónico",
     "placeholder_phone": "Escriba su teléfono",
+    "language": "Idioma",
+    "lang_pt": "PT-br",
+    "lang_en": "EN-us",
+    "lang_es": "ES-es",
     "bank_data": {
       "title": "Datos bancarios",
       "description": "Pix, agencia y cuenta",
@@ -654,5 +658,11 @@
       "home": "Residencial",
       "commercial": "Comercial"
     }
+  },
+  "nav": {
+    "home": "Inicio",
+    "payments": "Pagos",
+    "agenda": "Agenda",
+    "profile": "Perfil"
   }
 }

+ 10 - 0
src/i18n/locales/pt.json

@@ -322,6 +322,10 @@
     "placeholder_name": "Digite seu nome",
     "placeholder_email": "Digite seu e-mail",
     "placeholder_phone": "Digite seu telefone",
+    "language": "Idioma",
+    "lang_pt": "PT-br",
+    "lang_en": "EN-us",
+    "lang_es": "ES-es",
     "bank_data": {
       "title": "Dados bancários",
       "description": "Pix, agência e conta",
@@ -654,5 +658,11 @@
       "home": "Casa",
       "commercial": "Comercial"
     }
+  },
+  "nav": {
+    "home": "Início",
+    "payments": "Pagamentos",
+    "agenda": "Agenda",
+    "profile": "Perfil"
   }
 }

+ 8 - 6
src/layouts/MainLayout.vue

@@ -50,6 +50,7 @@
 import { computed, useTemplateRef, watch } from "vue";
 import { useQuasar } from "quasar";
 import { useRoute } from "vue-router";
+import { useI18n } from "vue-i18n";
 
 defineOptions({
   name: "MainLayout",
@@ -58,31 +59,32 @@ defineOptions({
 const $q = useQuasar();
 const route = useRoute();
 const scrollAreaRef = useTemplateRef("scrollAreaRef");
+const { t } = useI18n();
 
 let oldValue = route.path;
 
-const navItems = [
+const navItems = computed(() => [
   {
     name: "DashboardPage",
-    label: "Início",
+    label: t('nav.home'),
     icon: "mdi-home-outline",
   },
   {
     name: "PagamentosPage",
-    label: "Pagamentos",
+    label: t('nav.payments'),
     icon: "mdi-credit-card-outline",
   },
   {
     name: "AgendaPage",
-    label: "Agenda",
+    label: t('nav.agenda'),
     icon: "mdi-calendar-blank-outline",
   },
   {
     name: "ProfilePage",
-    label: "Perfil",
+    label: t('nav.profile'),
     icon: "mdi-account-circle-outline",
   },
-];
+]);
 
 const isNavItemActive = (item) => route.name === item.name;
 

+ 26 - 3
src/pages/profile/ProfileEditDialog.vue

@@ -57,9 +57,16 @@
                 :placeholder="$t('profile.placeholder_phone')"
               />
             </div>
-          </div>
 
-          <q-space/>
+            <div>
+              <div class="text-weight-bold text-grey-8 q-mb-sm">{{ $t('profile.language') }}</div>
+              <div class="row q-gutter-x-md">
+                <q-radio v-model="selectedLocale" val="pt" :label="$t('profile.lang_pt')" color="primary" class="text-text" keep-color @update:model-value="onLocaleChange" />
+                <q-radio v-model="selectedLocale" val="en" :label="$t('profile.lang_en')" color="primary" class="text-text" keep-color @update:model-value="onLocaleChange" />
+                <q-radio v-model="selectedLocale" val="es" :label="$t('profile.lang_es')" color="primary" class="text-text" keep-color @update:model-value="onLocaleChange" />
+              </div>
+            </div>
+          </div>
 
           <div class="q-pa-xl q-mt-md">
             <q-btn
@@ -83,9 +90,10 @@
 
 <script setup>
 import { ref, onMounted } from 'vue';
-import { useDialogPluginComponent } from 'quasar';
+import { useDialogPluginComponent, Cookies } from 'quasar';
 import { updateUser } from 'src/api/user';
 import { useFormUpdateTracker } from 'src/composables/useFormUpdateTracker';
+import { i18n } from 'src/boot/i18n';
 
 const props = defineProps({
   userData: {
@@ -101,6 +109,21 @@ const loading = ref(false);
 const submitting = ref(false);
 const userId = ref(null);
 
+const normalizeLocale = (loc) => {
+  if (!loc) return 'pt'
+  const l = String(loc).toLowerCase()
+  if (l.startsWith('pt')) return 'pt'
+  if (l.startsWith('en')) return 'en'
+  if (l.startsWith('es')) return 'es'
+  return 'pt'
+}
+const selectedLocale = ref(normalizeLocale(i18n.global.locale.value ?? i18n.global.locale))
+
+const onLocaleChange = (val) => {
+  i18n.global.locale.value = val
+  Cookies.set('locale', val, { expires: 365, path: '/' })
+}
+
 const { form, hasUpdatedFields, setUpdateFormAsOriginal } = useFormUpdateTracker({
   name: '',
   email: '',