# Vue: GTStringOptions
URL: https://generaltranslation.com/zh/docs/vue/reference/types/gt-string-options.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 使用静态上下文消除纯字符串 目录 查找的歧义。GTStringOptions 的 API 参考。

[`useGT()`](/docs/vue/reference/composables/use-gt)、[`t()`](/docs/vue/reference/functions/t)、[`msg()`](/docs/vue/reference/functions/msg) 以及 [`useMessages()`](/docs/vue/reference/composables/use-messages) 的原始字符串调用共用此选项对象。

## 概述 [#overview]

```ts
type GTStringOptions = {
  $context?: string;
};
```

| Property               | Description          | Type     | Optional | Default |
| ---------------------- | -------------------- | -------- | -------- | ------- |
| [`$context`](#context) | 计算目录哈希时，用于区分相同的源字符串。 | `string` | 是        | —       |

## `$context` [#context]

**类型** `string` · **可选** · **默认值** —

当同一源文本在不同场景下需要不同的翻译时，可使用上下文：

```ts
gt('Open', { $context: 'button that opens a file' });
gt('Open', { $context: 'adjective for an available store' });
```

上下文会影响 目录 identity，但不会显示出来。请在提取的调用中将其保持为静态值，以确保 CLI 和 运行时 计算出相同的键。

## 不支持的选项 [#unsupported]

Vue 的纯字符串查找刻意不支持插值变量、`$format`、`$locale`、`$maxChars` 或 `$requiresReview`，也不会解析 ICU 语法。花括号及其他消息格式字符会按字面保留。

如需使用运行时值，请将 [`<T>`](/docs/vue/reference/components/t) 与 [`<Var>`](/docs/vue/reference/components/var) 配合使用。丰富的翻译元数据应放在 [`<T>`](/docs/vue/reference/components/t) 上，而不是 `GTStringOptions` 中。

## 示例 [#example]

```vue title="src/AccountStatus.vue"
<script setup lang="ts">
import { useGT } from 'gt-vue';

const gt = useGT();
</script>

<template>
  <span>{{ gt('Active', { $context: 'account status' }) }}</span>
</template>
```

## Sitemap

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