Skip to main content

Tolgee SDK Version 6 released!

· 2 min read
Štěpán Granát
SDK v6SDK v6

With Tolgee SDK Version 6, fetching translations for your Next.js applications is easier than ever. You can prefetch translation data on the server and seamlessly pass it to the client, ensuring smooth and efficient localization.

Fetching Required Translations with loadRequired

The loadRequired method fetches translations based on the current language and namespace settings. Use it on the server to prefetch data and on the client to avoid extra fetches:

// Server-side
const translations = JSON.stringify(await tolgee.loadRequired());

// Client-side
tolgee.addStaticData(JSON.parse(translations));

This approach ensures the client has the translations ready without additional requests. Check the next.js integration guide to see how it's used.

Advanced Prefetching with loadMatrix

For greater control, use loadMatrix to prefetch specific languages and namespaces.

// Fetch translations for multiple languages and namespaces
const translations = await tolgee.loadMatrix({
languages: ['en', 'cs'],
namespaces: ['common', 'info']
});

To prefetch all namespaces for a language:

await tolgee.loadMatrix({
languages: ['en'],
namespaces: 'all'
});
t('app_title', { ns: 'info' });

These tools make it simple to fetch and render translations, streamlining the localization process for server-rendered and server components.

Breaking changes

Version 6 is just a mild update, so breaking changes are minimal.

Read the migration guide to see what has changed.

React banner

Štěpán Granát
Štěpán is a passionate developer responsible for Frontend and SDK development at Tolgee. He's on a mission to make software localization as easy as pie while keeping it smart. 🧠