| 1 |
import { useLabelsStore } from '@/stores/labels' |
| 2 |
|
| 3 |
/** |
| 4 |
* Composable function to provide easy access to labels throughout the application |
| 5 |
* @returns Object with getLabel function and allLabels getter |
| 6 |
*/ |
| 7 |
export function useLabels() { |
| 8 |
const labelsStore = useLabelsStore() |
| 9 |
|
| 10 |
/** |
| 11 |
* Get a label by key with optional fallback value |
| 12 |
* @param key The label key to retrieve |
| 13 |
* @param fallback Optional fallback text if label doesn't exist |
| 14 |
* @returns The label string or fallback value |
| 15 |
*/ |
| 16 |
const getLabel = (key: string, fallback: string = ''): string => { |
| 17 |
return labelsStore.getLabel(key, fallback) |
| 18 |
} |
| 19 |
|
| 20 |
return { |
| 21 |
getLabel, |
| 22 |
allLabels: labelsStore.allLabels, |
| 23 |
} |
| 24 |
} |
| 25 |
|