Get all key / values from namespace json file by calling translate function without any keys #1073
-
What version of this package are you using? What problem do you want to solve? What do you think is the correct solution to this problem? basket.json file {
"heading": "Your Basket",
"total": "Total",
"basketTotal": "Basket Total",
"grandTotal": "Grand Total",
"totalGoods": "Total Goods"
} Basket.js component Instead of doing this: const { t: translate } = useTranslation('basket');
// repeating all the keys from basket.json
const basketTranslation = {
heading: translate('basket:heading'),
total: translate('basket:total'),
basketTotal: translate('basket:basketTotal'),
grandTotal: translate('basket:grandTotal'),
totalGoods: translate('basket:totalGoods'),
}; we get the same result by simply doing this: const { t: translate } = useTranslation('basket');
const basketTranslation = translate('basket'); Are you willing to submit a pull request to implement this change? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Is currently possible with: t('namespace:.', { count: 1 }, { returnObjects: true })
/*
{
"array-example": [
{ "example": "Example 1" },
{ "another-example": "Another example 1" }
]
}
*/ namespace: {
"array-example": [
{ "example": "Example {{count}}" },
{ "another-example": "Another example {{count}}" }
]
} docs: https://github.com/aralroca/next-translate#7-nested-translations |
Beta Was this translation helpful? Give feedback.
Is currently possible with:
namespace:
docs: https://github.com/aralroca/next-translate#7-nested-translations