import {isOfType} from '@myparcel/ts-utils'; import {type SelectOption, type SelectOptionValue, type SelectOptionWithLabel} from '../../types'; import {type useLanguage} from '../../composables'; export const translateSelectOption = ( option: SelectOption, translate: ReturnType['translate'], ): SelectOptionWithLabel => { const hasLabel = isOfType(option, 'label'); const translatedOption = {...option} as SelectOptionWithLabel; translatedOption.label = hasLabel ? translate(option.label) : option.plainLabel; return Object.freeze(translatedOption) as SelectOptionWithLabel; };