Enables translation of strings.

This commit is contained in:
mateuswetah 2022-05-26 17:40:23 -03:00
parent 9fa43f10c8
commit 6b0cdd01d7
13 changed files with 174 additions and 25 deletions

View File

@ -10,6 +10,7 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies { dependencies {
implementation project(':capacitor-app') implementation project(':capacitor-app')
implementation project(':capacitor-device')
implementation project(':capacitor-haptics') implementation project(':capacitor-haptics')
implementation project(':capacitor-keyboard') implementation project(':capacitor-keyboard')
implementation project(':capacitor-status-bar') implementation project(':capacitor-status-bar')

View File

@ -3,6 +3,10 @@
"pkg": "@capacitor/app", "pkg": "@capacitor/app",
"classpath": "com.capacitorjs.plugins.app.AppPlugin" "classpath": "com.capacitorjs.plugins.app.AppPlugin"
}, },
{
"pkg": "@capacitor/device",
"classpath": "com.capacitorjs.plugins.device.DevicePlugin"
},
{ {
"pkg": "@capacitor/haptics", "pkg": "@capacitor/haptics",
"classpath": "com.capacitorjs.plugins.haptics.HapticsPlugin" "classpath": "com.capacitorjs.plugins.haptics.HapticsPlugin"

View File

@ -5,6 +5,9 @@ project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/
include ':capacitor-app' include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android') project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
include ':capacitor-device'
project(':capacitor-device').projectDir = new File('../node_modules/@capacitor/device/android')
include ':capacitor-haptics' include ':capacitor-haptics'
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android') project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')

84
package-lock.json generated
View File

@ -2151,6 +2151,11 @@
"tslib": "^2.1.0" "tslib": "^2.1.0"
} }
}, },
"@capacitor/device": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@capacitor/device/-/device-1.1.2.tgz",
"integrity": "sha512-1i6yvuSC7Ys7fs4JsUtfwG/00d2FF2TvWpbYs7YbkXhp1vOTL510gwjc5S6FTyhh8M9sAaUU5tKB68XwlSK/GA=="
},
"@capacitor/haptics": { "@capacitor/haptics": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/@capacitor/haptics/-/haptics-1.1.4.tgz", "resolved": "https://registry.npmjs.org/@capacitor/haptics/-/haptics-1.1.4.tgz",
@ -2311,6 +2316,74 @@
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
"dev": true "dev": true
}, },
"@intlify/core-base": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.1.10.tgz",
"integrity": "sha512-So9CNUavB/IsZ+zBmk2Cv6McQp6vc2wbGi1S0XQmJ8Vz+UFcNn9MFXAe9gY67PreIHrbLsLxDD0cwo1qsxM1Nw==",
"requires": {
"@intlify/devtools-if": "9.1.10",
"@intlify/message-compiler": "9.1.10",
"@intlify/message-resolver": "9.1.10",
"@intlify/runtime": "9.1.10",
"@intlify/shared": "9.1.10",
"@intlify/vue-devtools": "9.1.10"
}
},
"@intlify/devtools-if": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.1.10.tgz",
"integrity": "sha512-SHaKoYu6sog3+Q8js1y3oXLywuogbH1sKuc7NSYkN3GElvXSBaMoCzW+we0ZSFqj/6c7vTNLg9nQ6rxhKqYwnQ==",
"requires": {
"@intlify/shared": "9.1.10"
}
},
"@intlify/message-compiler": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.1.10.tgz",
"integrity": "sha512-+JiJpXff/XTb0EadYwdxOyRTB0hXNd4n1HaJ/a4yuV960uRmPXaklJsedW0LNdcptd/hYUZtCkI7Lc9J5C1gxg==",
"requires": {
"@intlify/message-resolver": "9.1.10",
"@intlify/shared": "9.1.10",
"source-map": "0.6.1"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}
}
},
"@intlify/message-resolver": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.1.10.tgz",
"integrity": "sha512-5YixMG/M05m0cn9+gOzd4EZQTFRUu8RGhzxJbR1DWN21x/Z3bJ8QpDYj6hC4FwBj5uKsRfKpJQ3Xqg98KWoA+w=="
},
"@intlify/runtime": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.1.10.tgz",
"integrity": "sha512-7QsuByNzpe3Gfmhwq6hzgXcMPpxz8Zxb/XFI6s9lQdPLPe5Lgw4U1ovRPZTOs6Y2hwitR3j/HD8BJNGWpJnOFA==",
"requires": {
"@intlify/message-compiler": "9.1.10",
"@intlify/message-resolver": "9.1.10",
"@intlify/shared": "9.1.10"
}
},
"@intlify/shared": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.1.10.tgz",
"integrity": "sha512-Om54xJeo1Vw+K1+wHYyXngE8cAbrxZHpWjYzMR9wCkqbhGtRV5VLhVc214Ze2YatPrWlS2WSMOWXR8JktX/IgA=="
},
"@intlify/vue-devtools": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.1.10.tgz",
"integrity": "sha512-5l3qYARVbkWAkagLu1XbDUWRJSL8br1Dj60wgMaKB0+HswVsrR6LloYZTg7ozyvM621V6+zsmwzbQxbVQyrytQ==",
"requires": {
"@intlify/message-resolver": "9.1.10",
"@intlify/runtime": "9.1.10",
"@intlify/shared": "9.1.10"
}
},
"@ionic/cli-framework": { "@ionic/cli-framework": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/@ionic/cli-framework/-/cli-framework-5.1.1.tgz", "resolved": "https://registry.npmjs.org/@ionic/cli-framework/-/cli-framework-5.1.1.tgz",
@ -14096,6 +14169,17 @@
"integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==", "integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==",
"dev": true "dev": true
}, },
"vue-i18n": {
"version": "9.1.10",
"resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.1.10.tgz",
"integrity": "sha512-jpr7gV5KPk4n+sSPdpZT8Qx3XzTcNDWffRlHV/cT2NUyEf+sEgTTmLvnBAibjOFJ0zsUyZlVTAWH5DDnYep+1g==",
"requires": {
"@intlify/core-base": "9.1.10",
"@intlify/shared": "9.1.10",
"@intlify/vue-devtools": "9.1.10",
"@vue/devtools-api": "^6.0.0-beta.7"
}
},
"vue-loader": { "vue-loader": {
"version": "17.0.0", "version": "17.0.0",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-17.0.0.tgz", "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-17.0.0.tgz",

View File

@ -14,6 +14,7 @@
"@capacitor/android": "3.5.1", "@capacitor/android": "3.5.1",
"@capacitor/app": "1.1.1", "@capacitor/app": "1.1.1",
"@capacitor/core": "3.4.3", "@capacitor/core": "3.4.3",
"@capacitor/device": "^1.1.2",
"@capacitor/haptics": "1.1.4", "@capacitor/haptics": "1.1.4",
"@capacitor/keyboard": "1.2.2", "@capacitor/keyboard": "1.2.2",
"@capacitor/status-bar": "1.0.8", "@capacitor/status-bar": "1.0.8",
@ -26,6 +27,7 @@
"core-js": "^3.22.7", "core-js": "^3.22.7",
"pinia": "^2.0.14", "pinia": "^2.0.14",
"vue": "^3.2.36", "vue": "^3.2.36",
"vue-i18n": "^9.1.10",
"vue-router": "^4.0.15", "vue-router": "^4.0.15",
"vuex": "^4.0.2" "vuex": "^4.0.2"
}, },

View File

@ -7,12 +7,25 @@
<script lang="ts"> <script lang="ts">
import { IonApp, IonRouterOutlet } from '@ionic/vue'; import { IonApp, IonRouterOutlet } from '@ionic/vue';
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { Device, DevicePlugin } from '@capacitor/device';
export default defineComponent({ export default defineComponent({
name: 'App', name: 'App',
components: { components: {
IonApp, IonApp,
IonRouterOutlet IonRouterOutlet
},
mounted() {
const device: DevicePlugin = Device;
device.getLanguageCode().then((res) => {
console.log('Default lang', res.value);
if (res.value.includes('-')) {
const language = res.value.split('-')[0];
this.$i18n.locale = language;
} else {
this.$i18n.locale = res.value;
}
})
} }
}); });
</script> </script>

View File

@ -0,0 +1,36 @@
export const translationStrings = {
en: {
collections: 'Collections',
label_view_all_collections: 'View all collections',
items: 'Items',
label_view_all_items: 'View all items',
label_loading: 'Loading...',
label_items_list: 'Items list',
label_collections_list: 'Collections list',
collection: 'Collection',
label_site_url: 'Archive site URL',
placeholder_site_url: 'https://my-tainacan-archive.com',
label_user_name: 'User name',
placeholder_user_name: 'your user name',
label_user_password: 'User password',
placeholder_user_password: 'your password here',
label_access_archive: 'Access archive'
},
pt: {
collections: "Coleções",
label_view_all_collections: "Ver todas as coleções",
items: 'Itens',
label_view_all_items: 'Ver todos os itens',
label_loading: 'Carregando...',
label_items_list: 'Lista de itens',
label_collections_list: 'Lista de coleções',
collection: 'Coleção',
label_site_url: 'URL do Site do Acervo',
placeholder_site_url: 'https://meu-acervo-tainacan.com',
label_user_name: 'Nome de usuário',
placeholder_user_name: 'seu nome de usuário aqui',
label_user_password: 'Senha do usuário',
placeholder_user_password: 'sua senha de usuário aqui',
label_access_archive: 'Acessar acervo'
}
}

View File

@ -29,11 +29,21 @@ import '@ionic/vue/css/display.css';
import './theme/variables.css'; import './theme/variables.css';
import './theme/core.css'; //importei do arquivo criado import './theme/core.css'; //importei do arquivo criado
/* Translation */
import { createI18n } from 'vue-i18n';
import { translationStrings } from './locales/translation-strings';
const i18n = createI18n({
locale: 'en', // set locale
fallbackLocale: 'en', // set fallback locale
messages: translationStrings, // set locale messages
})
const app = createApp(App) const app = createApp(App)
.use(IonicVue) .use(IonicVue)
.use(router) .use(router)
.use(createPinia()); .use(createPinia())
.use(i18n);
app.component('base-layout', BaseLayout); app.component('base-layout', BaseLayout);
app.component('base-collectionlist', CollectionList); app.component('base-collectionlist', CollectionList);

View File

@ -1,8 +1,8 @@
<template> <template>
<base-layout page-title="Collection" page-default-back-link="/collections"> <base-layout :page-title="$t('collection')" page-default-back-link="/collections">
<ion-loading <ion-loading
:is-open="isLoading" :is-open="isLoading"
message="Carregando..." :message="$t('label_loading')"
> >
</ion-loading> </ion-loading>
<items-list :items="tainacanStore.collectionItems"></items-list> <items-list :items="tainacanStore.collectionItems"></items-list>

View File

@ -1,14 +1,11 @@
<template> <template>
<base-layout page-title="Collections list" page-default-back-link="/"> <base-layout :page-title="$t('label_collections_list')" page-default-back-link="/">
<ion-loading <ion-loading
:is-open="isLoading" :is-open="isLoading"
message="Carregando..." :message="$t('label_loading')"
> >
</ion-loading> </ion-loading>
<ion-list> <ion-list>
<ion-list-header>
Coleções
</ion-list-header>
<collections-list :collections="tainacanStore.collections"></collections-list> <collections-list :collections="tainacanStore.collections"></collections-list>
</ion-list> </ion-list>
</base-layout> </base-layout>
@ -17,7 +14,7 @@
<script> <script>
import CollectionsList from '@/components/lists/CollectionsList.vue'; import CollectionsList from '@/components/lists/CollectionsList.vue';
import BaseLayout from '@/components/base/BaseLayout.vue'; import BaseLayout from '@/components/base/BaseLayout.vue';
import { IonLoading, IonListHeader, IonList } from '@ionic/vue'; import { IonLoading, IonList } from '@ionic/vue';
import { import {
useTainacanStore useTainacanStore
@ -30,8 +27,7 @@ export default {
CollectionsList, CollectionsList,
BaseLayout, BaseLayout,
IonLoading, IonLoading,
IonList, IonList
IonListHeader
}, },
setup() { setup() {
const isLoading = ref(false); const isLoading = ref(false);

View File

@ -2,25 +2,25 @@
<base-layout> <base-layout>
<ion-loading <ion-loading
:is-open="isLoading" :is-open="isLoading"
message="Carregando..." :message="$t('label_loading')"
> >
</ion-loading> </ion-loading>
<ion-list> <ion-list>
<ion-list-header> <ion-list-header>
Coleções {{ $t('collections') }}
</ion-list-header> </ion-list-header>
<collections-list :collections="tainacanStore.collections"></collections-list> <collections-list :collections="tainacanStore.collections"></collections-list>
</ion-list> </ion-list>
<ion-button fill="clear" size="small" routerLink="/collections"> <ion-button fill="clear" size="small" routerLink="/collections">
Acessar lista completa de coleções {{ $t('label_view_all_collections') }}
</ion-button> </ion-button>
<ion-list> <ion-list>
<ion-list-header> <ion-list-header>
Items {{ $t('items') }}
</ion-list-header> </ion-list-header>
<items-list :items="tainacanStore.items"></items-list> <items-list :items="tainacanStore.items"></items-list>
<ion-button fill="clear" size="small" routerLink="/items"> <ion-button fill="clear" size="small" routerLink="/items">
Acessar lista completa de itens {{ $t('label_view_all_items') }}
</ion-button> </ion-button>
</ion-list> </ion-list>
</base-layout> </base-layout>

View File

@ -1,8 +1,8 @@
<template> <template>
<base-layout page-title="Items List" page-default-back-link="/collections"> <base-layout :page-title="$t('label_items_list')" page-default-back-link="/collections">
<ion-loading <ion-loading
:is-open="isLoading" :is-open="isLoading"
message="Carregando..." :message="$t('label_loading')"
> >
</ion-loading> </ion-loading>
<items-list :items="tainacanStore.items"></items-list> <items-list :items="tainacanStore.items"></items-list>

View File

@ -8,10 +8,10 @@
<ion-list class="ion-no-margin" inset> <ion-list class="ion-no-margin" inset>
<ion-item> <ion-item>
<ion-label position="floating"> <ion-label position="floating">
URL do Site do Acervo {{ $t('label_site_url') }}
</ion-label> </ion-label>
<ion-input <ion-input
placeholder="https://my-tainacan-museum.com" :placeholder="$t('placeholder_site_url')"
autofocus="true" autofocus="true"
id="siteUrl" id="siteUrl"
type="url" type="url"
@ -24,10 +24,10 @@
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-label position="floating"> <ion-label position="floating">
Nome do usuário {{ $t('label_user_name') }}
</ion-label> </ion-label>
<ion-input <ion-input
placeholder="seu nome de usuário aqui" :placeholder="$t('placeholder_user_name')"
id="userLogin" id="userLogin"
type="text" type="text"
name="userLogin" name="userLogin"
@ -40,10 +40,10 @@
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-label position="floating"> <ion-label position="floating">
Senha do usuário {{ $t('label_user_password') }}
</ion-label> </ion-label>
<ion-input <ion-input
placeholder="sua senha de usuário aqui" :placeholder="$t('placeholder_user_password')"
id="userPassword" id="userPassword"
type="password" type="password"
name="userPassword" name="userPassword"
@ -56,7 +56,7 @@
</ion-list> </ion-list>
<br> <br>
<ion-button type="submit" fill="clear"> <ion-button type="submit" fill="clear">
Acessar acervo {{ $t('label_access_archive') }}
<ion-icon slot="end" :icon="arrowForwardOutline"></ion-icon> <ion-icon slot="end" :icon="arrowForwardOutline"></ion-icon>
</ion-button> </ion-button>
</form> </form>