Back

gt-next@6.14.0

Jackie Chen avatarJackie Chen
gt-nextgt-i18ngt-nodegt-tanstack-startversion-idhooki18n

Overview

A new useVersionId hook and getVersionId helper function are now available across all GT JavaScript packages. These let you read the _versionId from your GT configuration at runtime — useful for debugging, cache-busting, logging, and tracking which version of your translations is currently active.

PackageVersionExport
gt-next6.14.0useVersionId (client + server), getVersionId (function)
gt-i18n0.7.0getVersionId (function)
gt-node0.4.0getVersionId (function)
gt-tanstack-start0.2.0getVersionId (function)
gt-i18n (Python)0.3.0get_version_id() (function)
gt-fastapi0.3.0get_version_id() (function)
gt-flask0.3.0get_version_id() (function)

Usage

Next.js (client)

import { useVersionId } from 'gt-next';

function DebugFooter() {
  const versionId = useVersionId();
  return <footer>Translation version: {versionId ?? 'unknown'}</footer>;
}

Next.js (server)

import { useVersionId } from 'gt-next/server';

export default function Page() {
  const versionId = useVersionId();
  // use in server components, logging, headers, etc.
}

Node / non-React

import { getVersionId } from 'gt-i18n';
// or: import { getVersionId } from 'gt-node';

console.log('Current translation version:', getVersionId());

Python (gt-fastapi / gt-flask)

from gt_i18n import get_version_id
# or: from gt_fastapi import get_version_id
# or: from gt_flask import get_version_id

print("Current translation version:", get_version_id())

You can also pass version_id directly to initialize_gt():

initialize_gt(version_id="abc123", ...)

Configuration

Set _versionId in your gt.config.json. This value is automatically set by the CLI when you run the translate command:

{
  "defaultLocale": "en",
  "locales": ["en", "es", "fr"],
  "_versionId": "abc123"
}

What's next

With locale and version ID now accessible at runtime, the next step is analytics tracking — giving developers visibility into which translations are actually being rendered alongside their analytics events.

The plan is to introduce hash aggregation: as translation components like <T>, gt(), and m() resolve at runtime, their hashes would be collected into a trackable set. A new useAnalytics() hook would let developers read the current set of resolved hashes at the moment an analytics event fires, and an <AnalyticsScope> wrapper would allow scoping that collection to specific parts of the React tree.