import { TranslateFn } from '@/types'

export function dynamicMessage(message: string, te: TranslateFn): string {
	const isDynamicText = message.includes('|')
	const [text, variable] = message.split('|')
	const [key, value] = (variable || '').split('=')

	return isDynamicText ? te(text, { [key]: value }) : te(message)
}
