# vue: Translating strings
URL: https://generaltranslation.com/en-US/docs/vue/guides/translating-strings.mdx
---
title: Translating strings
description: How to translate Vue labels, attributes, and shared strings with useGT and useMessages.
related:
links:
- /docs/vue/guides/translating-content
- /docs/vue/guides/developing-spa-translations
- /docs/vue/guides/formatting-variables
- /docs/vue/guides/configuring
---
Use [`useGT()`](/docs/vue/reference/composables/use-gt) for strings that cannot be expressed as template content, such as placeholders, accessible labels, and values passed to another component. Use [`msg()`](/docs/vue/reference/functions/msg) with [`useMessages()`](/docs/vue/reference/composables/use-messages) when a static message is declared in one module and rendered in another.
## Translate with `useGT` [#use-gt]
Call [`useGT()`](/docs/vue/reference/composables/use-gt) during component setup, then call its returned function from the template:
```vue
```
Use a string literal so the CLI can extract it. Missing catalog entries return the source string.
The only supported option is a static `$context`:
```vue
```
Braces are literal text. [`useGT()`](/docs/vue/reference/composables/use-gt) does not process ICU syntax, interpolate variables, or accept React string options such as `$id`, `$maxChars`, and `$format`.
## Keep translated results reactive [#reactivity]
The function returned by [`useGT()`](/docs/vue/reference/composables/use-gt) reads the active catalog when it is called. Call it from a template, computed value, or reactive effect when the result should update after a locale or catalog change:
```vue
{{ pageTitle }}
```
`const pageTitle = gt('Account settings')` translates once during setup and stores a snapshot. It does not run again when a [`createGT()`](/docs/vue/reference/functions/create-gt) plugin switches locale.
## Register shared messages [#messages]
Use [`msg()`](/docs/vue/reference/functions/msg) to register static strings in a shared module. It marks content for extraction; it does not perform a translation lookup.
```ts title="src/messages.ts"
import { msg } from 'gt-vue';
export const statusMessages = {
active: msg('Active', { $context: 'account status' }),
paused: msg('Paused', { $context: 'account status' }),
};
```
Resolve the selected message with [`useMessages()`](/docs/vue/reference/composables/use-messages) where it is rendered:
```vue title="src/components/StatusBadge.vue"
{{ label }}
```
Without options, [`msg()`](/docs/vue/reference/functions/msg) returns the original string unchanged. With `$context`, it adds opaque lookup metadata that [`useMessages()`](/docs/vue/reference/composables/use-messages) reads. Do not parse or store assumptions about that encoded representation.
## Translate content with runtime values [#variables]
Plain string lookups do not interpolate runtime data. Put the complete phrase in [``](/docs/vue/reference/components/t) and mark the changing value with [``](/docs/vue/reference/components/var):
```vue
Welcome back, {{ accountName }}!
```
Use [``](/docs/vue/reference/components/num), [``](/docs/vue/reference/components/currency), and [``](/docs/vue/reference/components/datetime) when the value also needs locale-aware formatting.
Browser-only SPAs that need a static lookup while modules are evaluated can use [`t()`](/docs/vue/reference/functions/t) after awaiting [`initializeGTSPA()`](/docs/vue/reference/functions/initialize-gt-spa). Follow [Developing with SPA translations](/docs/vue/guides/developing-spa-translations) to preserve the required import order.
## Next steps
- /docs/vue/guides/translating-content
- /docs/vue/guides/developing-spa-translations
- /docs/vue/guides/formatting-variables
- /docs/vue/guides/configuring