mirror of
https://github.com/BlossomiShymae/clean-cuts.git
synced 2025-12-06 18:20:47 +01:00
Add i18n support for data
This commit is contained in:
@@ -49,23 +49,29 @@
|
||||
<script setup lang="ts">
|
||||
import Pagination from '~/components/Pagination.vue';
|
||||
import useClient from '../../composables/useClient';
|
||||
import useLocale from '~/composables/useLocale';
|
||||
import usePagination from '../../composables/usePagination';
|
||||
import useIsNumeric from '../../composables/useIsNumeric';
|
||||
|
||||
const { client } = useClient();
|
||||
const { currentLocale } = useLocale();
|
||||
const getIcons = async () => (await client.summonerIcons.listAsync({locale: currentLocale.value, version: "latest"}))
|
||||
.sort((a, b) => a.id - b.id);
|
||||
|
||||
const query = ref("")
|
||||
|
||||
const icons = (await client.summonerIcons.listAsync({locale: "default", version: "latest"}))
|
||||
.sort((a, b) => a.id - b.id);
|
||||
const icons = ref(await getIcons());
|
||||
watch(currentLocale, async() => {
|
||||
icons.value = await getIcons();
|
||||
});
|
||||
|
||||
const { isNumeric } = useIsNumeric();
|
||||
const p = computed(() => {
|
||||
let filtered = [];
|
||||
if (isNumeric(query.value))
|
||||
filtered = icons.filter((x) => x.id == parseInt(query.value, 10));
|
||||
filtered = icons.value.filter((x) => x.id == parseInt(query.value, 10));
|
||||
else
|
||||
filtered = icons.filter((x) => x.title.toLowerCase().includes(query.value.toLowerCase()));
|
||||
filtered = icons.value.filter((x) => x.title.toLowerCase().includes(query.value.toLowerCase()));
|
||||
|
||||
return usePagination(filtered, 100);
|
||||
});
|
||||
|
||||
@@ -20,13 +20,20 @@
|
||||
import Badge from '~/components/Badge.vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import useClient from '../../../composables/useClient';
|
||||
import useLocale from '~/composables/useLocale';
|
||||
import { SummonerIcon } from '~/core/models';
|
||||
|
||||
const route = useRoute();
|
||||
const id = route.params.id as unknown;
|
||||
|
||||
const { client } = useClient();
|
||||
const { currentLocale } = useLocale();
|
||||
const getIcons = async () => await client.summonerIcons.listAsync({locale: currentLocale.value, version: "latest"});
|
||||
|
||||
const icons = await client.summonerIcons.listAsync({locale: "default", version: "latest"});
|
||||
const icon = icons.find((x) => x.id == id) || new SummonerIcon({});
|
||||
const icons = ref(await getIcons());
|
||||
watch(currentLocale, async() => {
|
||||
icons.value = await getIcons();
|
||||
});
|
||||
|
||||
const icon = icons.value.find((x) => x.id == id) || new SummonerIcon({});
|
||||
</script>
|
||||
Reference in New Issue
Block a user