# General Translation Changelog: gt-next 6.14.0: 在运行时读取翻译版本
URL: https://generaltranslation.com/zh/blog/gt-next_v6_14_0.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 
Authors: Jackie Chen
Published: 2026-03-18

## 概述

现在，所有 GT JavaScript 包都已提供新的 `useVersionId` Hook 和 [`getVersionId`](/docs/node/reference/functions/get-version-id) 辅助函数。你可以用它们在运行时从 GT 配置中读取 `_versionId`，这对于调试、缓存失效、日志记录，以及跟踪当前生效的翻译版本都很有帮助。

| 包                   | 版本     | 导出项                                                                                            |
| ------------------- | ------ | ---------------------------------------------------------------------------------------------- |
| `gt-next`           | 6.14.0 | `useVersionId` (客户端和服务端) ，[`getVersionId`](/docs/node/reference/functions/get-version-id) (函数) |
| `gt-i18n`           | 0.7.0  | [`getVersionId`](/docs/node/reference/functions/get-version-id) (函数)                           |
| `gt-node`           | 0.4.0  | [`getVersionId`](/docs/node/reference/functions/get-version-id) (函数)                           |
| `gt-tanstack-start` | 0.2.0  | [`getVersionId`](/docs/node/reference/functions/get-version-id) (函数)                           |
| `gt-i18n` (Python)  | 0.3.0  | [`get_version_id()`](/docs/python/reference/functions/get-version-id) (函数)                     |
| `gt-fastapi`        | 0.3.0  | [`get_version_id()`](/docs/python/reference/functions/get-version-id) (函数)                     |
| `gt-flask`          | 0.3.0  | [`get_version_id()`](/docs/python/reference/functions/get-version-id) (函数)                     |

## 用法

### Next.js (客户端) 

```tsx
import { useVersionId } from 'gt-next';

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


### Next.js (服务端) 

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

export default function Page() {
  const versionId = useVersionId();
  // 用于服务器组件、日志记录、请求头等。
}
```


### Node / 非 React 环境

```ts
import { getVersionId } from 'gt-i18n';
// 或: import { getVersionId } from 'gt-node';

console.log('当前翻译版本:', getVersionId());
```


### Python (gt-fastapi / gt-flask)

```python
from gt_i18n import get_version_id
# 或: from gt_fastapi import get_version_id
# 或: from gt_flask import get_version_id

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

你也可以直接向 [`initialize_gt()`](/docs/python/reference/functions/initialize-gt) 传入 `version_id`：

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

## 配置

在 `gt.config.json` 中设置 `_versionId`。运行 [`translate`](/docs/cli/reference/commands/translate) 命令时，CLI 会自动设置该值：

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

## 接下来

现在已经可以在运行时访问区域设置和版本 ID，下一步就是**分析追踪**——让开发者能够了解在分析事件触发时，实际渲染了哪些翻译内容。

计划是引入哈希聚合：当 [`<T>`](/docs/react/reference/components/t)、`gt()` 和 `m()` 这类翻译组件或调用在运行时完成解析后，它们的哈希会被收集到一个可追踪的集合中。新的 `useAnalytics()` hook 将让开发者在分析事件触发时读取当前这组已解析哈希，而 `<AnalyticsScope>` 包装组件则可将这类收集限定在 React 树的特定部分。

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
