Zurück

gt-react@10.8.0

Ernest McCarter avatarErnest McCarter
gt-react10.8.0feature flagsi18ntranslation

Overview

In gt-react 10.8.0, we've added feature flag support through the enableI18n field. This allows you to conditionally disable internationalization, with support for both synchronous and asynchronous loading patterns.


Synchronous Behavior

When enableI18n is set to false, i18n functionality is disabled by:

  • Setting the locale list to only the default locale
  • Setting the user's locale to the default locale
<GTProvider enableI18n={false}>
  {/* i18n disabled - only default locale available */}
</GTProvider>

Asynchronous Behavior

For dynamic feature flags, use enableI18nLoaded to indicate loading state:

<GTProvider 
  enableI18n={featureFlag} 
  enableI18nLoaded={isLoaded}
>
  {/* Content */}
</GTProvider>

When enableI18nLoaded is not undefined:

  • false: Feature flag is loading (uses default enableI18n value)
  • true: Feature flag has finished loading

During loading, the library checks the generaltranslation.enable-i18n cookie to determine the current state. Once loaded, the explicit enableI18n value takes precedence.


SSG/SSR Considerations

With SSG, the first render cycle is sacrificed when the default enableI18n value is false, as static generation cannot determine the runtime feature flag state.

SSR currently behaves similarly, though we plan to add proper SSR support for Next.js Pages Router in future releases. For Next.js App Router, use gt-next instead.