PluginProbe
The Innovative Form Builder – IvyForms / 0.4
The Innovative Form Builder – IvyForms v0.4
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.4, at frontend/src/stores/labels.ts

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