# ivyforms/0.8/frontend/src/stores/labels.ts

The Innovative Form Builder – IvyForms, version 0.8. 25 lines.

- Page: https://pluginprobe.com/plugins/ivyforms/0.8/code/frontend/src/stores/labels.ts
- Raw: https://pluginprobe.com/plugins/ivyforms/0.8/raw/frontend/src/stores/labels.ts
- Modified: 2026-01-13T11:11:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ivyforms/0.8/code/frontend/src/stores/labels.ts#L10-L20`.

```typescript
import { defineStore } from 'pinia'

// Note: Window.wpIvyLabels is defined in src/types/global.d.ts
// No need to duplicate declaration here

export const useLabelsStore = defineStore('labels', {
  state: () => ({
    labels: {} as Record<string, string>,
  }),
  actions: {
    initialize() {
      // Get labels from the global variable injected by WordPress
      if (typeof window.wpIvyLabels !== 'undefined') {
        this.labels = window.wpIvyLabels
      }
    },
    getLabel(key: string, fallback: string = ''): string {
      return this.labels[key] || fallback
    },
  },
  getters: {
    allLabels: (state) => state.labels,
  },
})

```
