Files
mixtape/zero.Backoffice.UI/app/stores/translations.ts
T

28 lines
555 B
TypeScript
Raw Normal View History

2021-12-06 15:32:45 +01:00
import { defineStore } from 'pinia';
2021-12-09 14:18:38 +01:00
import uiApi from '../ui/api';
2021-12-06 15:32:45 +01:00
export type TranslationState = {
culture: string,
translations: Record<string, string>
};
export const useTranslationStore = defineStore('zero.translations', {
state: () => ({
culture: null,
2021-12-09 14:18:38 +01:00
translations: { }
2021-12-06 15:32:45 +01:00
} as TranslationState),
2021-12-06 16:18:58 +01:00
actions: {
find(key: string): string
2021-12-06 15:32:45 +01:00
{
2021-12-06 16:18:58 +01:00
return this.translations[key.toLowerCase()];
2021-12-09 14:18:38 +01:00
},
async setup()
{
2021-12-14 11:54:36 +01:00
var result = await uiApi.getTranslations();
this.translations = result.data;
2021-12-06 15:32:45 +01:00
}
2021-12-06 16:18:58 +01:00
}
2021-12-06 15:32:45 +01:00
});