The built-in casing utilities $_.title, $_.capital, $_.lower, and $_.upper were removed in v3. To achieve the same results, use standard JavaScript string methods on the result of the translation store, or implement custom helper functions.
Example of manual implementation for title and capital:
function capital(str: string) {
return str.replace(/(^|\s)\S/, l => l.toLocaleUpperCase())
}
function title(str: string) {
return str.replace(/(^|\s)\S/g, l => l.toLocaleUpperCase())
}
Usage with the translation store:
// Lowercase/Uppercase via native JS
$_('message.id').toLocaleLowerCase()
$_('message.id').toLocaleUpperCase()
// Title/Capital via custom helpers
title($_('message.id'))
capital($_('message.id'))
function capital(str: string) {
return str.replace(/(^|\s)\S/, l => l.toLocaleUpperCase())
}
function title(str: string) {
return str.replace(/(^|\s)\S/g, l => l.toLocaleUpperCase())
}
$_('message.id').toLocaleLowerCase()
$_('message.id').toLocaleUpperCase()
title($_('message.id'))
capital($_('message.id'))