3 ms·
I work on a project where people decided to refer to translations by doing the equivalent of: :label="$translate(getProductSectionLabel('title'))" where the
by KronisLV 2y ago
I work on a project where people decided to refer to translations by doing the equivalent of:
:label="$translate(getProductSectionLabel('title'))"
where the logic is a bit like:
const getProductSectionLabel = (code) => `myapp.sales.sections.products.${code}`
and then the actual values are in a nested structure, like:
myapp: {
sales: {
sections: {
products: {
title: "Products"
...
}
...
}
...
}
...
}
People seem to have gone for that because writing that first part is simpler within the component, but I couldn't get across that this makes the codebase harder to navigate.
Meanwhile, my personal codebases are more like:
:label"$translate('myapp-sales-products-title')"
and the translation file also has the equivalent of:
myapp-sales-products-title: "Products"
which is way simpler at the expense of some more duplication (easily mitigated by compressing the translations).