Files
homebox/frontend/components/global/Currency.vue
Nikolai Oakfield 3a4fae5eb8 Fix untranslated strings (#756)
* add missing translations and translate page titles

* fix: actually use the declared localized variables

* lint and prettier fixes

* add missing translations for toasts and confirms

* use components for shift/enter keys, add pluralization for photos, and fix primary photo conditional

* remove prop defaults since we're computing these anyways
2025-05-29 12:56:30 +00:00

46 lines
959 B
Vue

<template>
<Suspense>
<template #default>
{{ formattedValue }}
</template>
<template #fallback> {{ $t("global.loading") }} </template>
</Suspense>
</template>
<script setup lang="ts">
import { ref, computed } from "vue";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
type Props = {
amount: string | number;
};
const props = defineProps<Props>();
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R>
? R
: any;
const fmt = ref<AsyncReturnType<typeof useFormatCurrency> | null>(null);
const loadFormatter = async () => {
fmt.value = await useFormatCurrency();
};
loadFormatter();
const formattedValue = computed(() => {
if (!fmt.value) {
return t("global.loading");
}
if (!props.amount || props.amount === "0") {
return fmt.value(0);
}
return fmt.value(props.amount);
});
</script>