The useTranslation()
composable returns the translation function.
The locale used by the translation function is the locale detected by the function defined in experimental.localeDetector
option.
declare function useTranslation<Schema extends Record<string, any> = {}, Event extends H3Event = H3Event>(
event: Event
): Promise<TranslationFunction<Schema, DefineLocaleMessage>>
export default defineEventHandler(async event => {
const t = await useTranslation(event)
return {
hello: t('hello')
}
})