Bot releases are hidden (Show)
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
My apologies. The releases 0.20.0 and 0.20.1 are broken because I did the build with the dependencies of another branch. In this release there are no changes in code level, I simply reinstalled dependencies and did the build again to make it work well.
The list of changes is the same as 0.20, check it out because there are 3 new features:
https://github.com/vinissimus/next-translate/releases/tag/0.20.0
😊
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
In this release we introduce 3 new features! 🔥
Until now, it was only possible to define the Trans
components as an array. Now we also support that components can be defined as an object:
// The defined dictionary enter is like:
// "example": "<component>The number is <b>{{count}}</b></component>",
<Trans
i18nKey="common:example"
components={{
component: <Component />,
b: <b className="red" />,
}}
values={{ count: 42 }}
/>
To avoid repetition, if in a component you always use the same namespace, you can tell the useTranslation
hook so you don't have to indicate it each time.
const { t, lang } = useTranslation('ns1') // default namespace (optional)
const title = t('title') // no need to add the ns1: on front
const example = t('ns2:example', { count: 3 }) // You can use other namespaces
If no translation exists you can define fallbacks (string|Array<string>
) to search for other translations:
const { t } = useTranslation()
const textOrFallback = t(
'ns:text',
{ count: 1 },
{
fallback: 'ns:fallback',
}
)
List of fallbacks:
const { t } = useTranslation()
const textOrFallback = t(
'ns:text',
{ count: 42 },
{
fallback: ['ns:fallback1', 'ns:fallbac2'],
}
)
In Trans Component:
<Trans
i18nKey="ns:example"
components={[<Component />, <b className="red" />]}
values={{ count: 42 }}
fallback={['ns:fallback1', 'ns:fallback2']} // or string with just 1 fallback
/>
For the future version 1.0 we are working to eliminate the "build step" with a fairly simple migration without losing features but gaining: hotrelading/refresh, no more pages_ workaround (working in the same Next.js pages folder), de-duping logic, improving TypeScript support, making it easier to migrate to future changes in the Next.js core and making next-translate easier to maintain and test.
At the moment it is being developed in an experimental branch: 1.0.0-experimental, and prereleases are being taken out so that you can try it out. In fact we would love it if you could contribute by testing the experimental version and reporting issues or PR in order to stabilize it 😊.
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago
Published by aralroca almost 4 years ago