# General Translation Changelog: gt-next 6.11.0: 翻译字符限制
URL: https://generaltranslation.com/zh/blog/gt-next_v6_11_0.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 
Authors: Ernest McCarter
Published: 2025-12-09

## 概述

**gt-next@6.11.0** 为翻译函数新增了对 `$maxChars` 参数的支持，基于 [`generaltranslation@8.1.0`](/devlog/generaltranslation_v8_1_0) 中引入的 [`formatCutoff()`](/docs/platform/core/reference/utility-functions/formatting/format-cutoff) 功能。

***

## 用法

`$maxChars` 参数可用于任何字符串翻译调用：

```javascript
gt('Welcome to our application', { $maxChars: 20 });
// AI 尝试将翻译控制在 20 个字符以内："Bienvenido a app"
```


### 字符限制处理

`$maxChars` 参数会触发两种不同的机制：

1. **AI 翻译优化**：AI 会接收字符限制，并尝试生成符合指定长度限制的译文。

2. **库截断**：如果任何译文 (来自 AI 或缓存) 超出字符限制，库会根据区域设置进行截断，以强制满足该限制。

```javascript
gt('Long description text', { $maxChars: 15 });
// AI 尝试生成简洁译文："Texto breve"
// 若结果超出限制："Texto de desc…"（已截断）
```

### 集成

兼容现有翻译方案：

```javascript
gt('User notification', {
  $context: 'mobile-alert',
  $maxChars: 30,
});
// AI 尝试将翻译控制在 30 个字符以内："Notificación usuario"
// 库在必要时进行截断："Notificación del usuario…"
```

该参数会影响翻译哈希，以确保不同的字符限制会生成独立的翻译条目。

## Sitemap

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