Add i18n support for data

This commit is contained in:
BlossomiShymae
2024-09-09 15:58:00 -05:00
parent b0491d569a
commit 90de82ba20
18 changed files with 210 additions and 41 deletions

View File

@@ -37,9 +37,15 @@
<script setup lang="ts">
import useClient from '../../composables/useClient';
import useLocale from "../../composables/useLocale";
const { client } = useClient();
const { currentLocale } = useLocale();
const getSummaries = async () => (await client.championSummaries.listAsync({locale: currentLocale.value, version: "latest"}))
.filter((x) => x.id != -1);
const summaries = (await client.championSummaries.listAsync({locale: "default", version: "latest"}))
.filter((x) => x.id != -1);
const summaries = ref(await getSummaries());
watch(currentLocale, async () => {
summaries.value = await getSummaries();
});
</script>

View File

@@ -49,14 +49,22 @@
import Badge from '~/components/Badge.vue';
import { useRoute } from 'vue-router';
import useClient from '../../../composables/useClient';
import useLocale from '~/composables/useLocale';
const route = useRoute();
const id = route.params.id as unknown;
const { client } = useClient();
const champion = await client.champions.getAsync(id as number, {locale: "default", version: "latest"});
const currentSkin = ref(champion.skins[0].getLoadScreen('latest'));
const { currentLocale } = useLocale();
const getChampion = async () => await client.champions.getAsync(id as number, {locale: currentLocale.value, version: "latest"});
const champion = ref(await getChampion());
watch(currentLocale, async () => {
champion.value = await getChampion();
});
const currentSkin = ref(champion.value.skins[0].getLoadScreen('latest'));
const swapLoadScreen = (id: number) => {
currentSkin.value = champion.skins.find((x) => x.id == id)?.getLoadScreen('latest') as string;
currentSkin.value = champion.value.skins.find((x) => x.id == id)?.getLoadScreen('latest') as string;
}
</script>