common and additional catalogs
import { defineMeekoConfig } from '@meekojs/meeko/framework'
export default defineMeekoConfig({
modules: ['@meekojs/i18n'],
i18n: {
defaultLocale: 'es',
catalogs: {
es: {
common: 'app/locales/es/common.json',
checkout: 'app/locales/es/checkout.json',
},
en: {
common: 'app/locales/en/common.json',
checkout: 'app/locales/en/checkout.json',
},
},
routes: { '/checkout': ['checkout'] },
},
})
common
is always loaded, together with the namespaces of
global, such as the catalog of a shared shell.
routes
maps exact IDs of the manifest to additional namespaces. Every language declares the same namespaces.
A real namespace on this page
This route loads the
checkout
namespace through the site's
routes
option. The following result comes from that catalog:
Confirm order
Your order has 3 products.
{
"checkout": {
"title": "Confirmar pedido",
"summary": "Tu pedido tiene {total} productos."
}
}Organizing the keys
The name of the namespace organizes loading; it does not add a prefix to the keys. Here
checkout.title
comes from the
checkout
object of the JSON. Keys of different namespaces must be unique.
The generated types include the keys of every namespace. Use each message on a route that loads its catalog: a key that TypeScript knows also needs to be available at runtime.