PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / stores / labels.ts

labels.ts in The Innovative Form Builder – IvyForms 0.9, at frontend/src/stores/labels.ts

25 lines 647 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { defineStore } from 'pinia'
2
3 // Note: Window.wpIvyLabels is defined in src/types/global.d.ts
4 // No need to duplicate declaration here
5
6 export const useLabelsStore = defineStore('labels', {
7 state: () => ({
8 labels: {} as Record<string, string>,
9 }),
10 actions: {
11 initialize() {
12 // Get labels from the global variable injected by WordPress
13 if (typeof window.wpIvyLabels !== 'undefined') {
14 this.labels = window.wpIvyLabels
15 }
16 },
17 getLabel(key: string, fallback: string = ''): string {
18 return this.labels[key] || fallback
19 },
20 },
21 getters: {
22 allLabels: (state) => state.labels,
23 },
24 })
25