# General Translation Changelog: gt-next 6.3.0: Translate strings anywhere with msg()
URL: https://generaltranslation.com/en-GB/blog/gt-next_v6_3_0.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 
Authors: Ernest McCarter
Published: 2025-08-27

## Overview

In **gt-next 6.3.0**, we&#39;re moving closer to a library that works well for both human developers and AI developers. Our guiding principle for this release was to **minimise disruption to existing code** while still introducing the essential functionality required for i18n.

To achieve this, we&#39;re introducing a new [`msg()`](/docs/react/reference/functions/msg) function for translating strings anywhere in your codebase. Previously, developers had to pass the `gt()` function from [`useGT()`](/docs/react/reference/hooks/use-gt) or [`getGT()`](/docs/react/nextjs/reference/functions/get-gt) up the call stack to translate a string. With [`msg()`](/docs/react/reference/functions/msg), you simply wrap the string once, and then pass it through `m()` at render time.

***

## A comparison

Historically, strings had to be wrapped by passing the `gt()` function through multiple layers:

```tsx title="constants.tsx"
export const greeting1 = 'Hello, world!'
export const getGreeting2 = (gt: any) => gt('Hello, world!')
```

```tsx title="Page.tsx"
import { greeting1, getGreeting2 } from './constants'

export default function Page() {
  const gt = useGT()
  return (
    <div>
      {greeting1}
      {getGreeting2(gt)}
    </div>
  )
}
```

Now, with [`msg()`](/docs/react/reference/functions/msg), strings can be declared directly as constants. The only requirement is that you pass them through `m()` (from [`useMessages()`](/docs/react/reference/hooks/use-messages) or [`getMessages()`](/docs/react/nextjs/reference/functions/get-messages)) when rendering them.

```tsx title="constants.tsx"
export const greeting1 = 'Hello, world!'
export const greeting2 = msg('Hello, world!')
```

```tsx title="Page.tsx"
import { greeting1, greeting2 } from './constants'

export default function Page() {
  const m = useMessages()
  return (
    <div>
      {greeting1}
      {m(greeting2)}
    </div>
  )
}
```

***

## Encoding and decoding

To support interpolation, the [`msg()`](/docs/react/reference/functions/msg) function returns an encoded message instead of a plain string. The format looks like this:

```
<interpolated content>:<base64 encoded string>
```

The base64-encoded portion contains a JSON object with:

* `$_hash`: Hash of the original string
* `$_source`: Parameters interpolated into the message
* `$id`: A custom unique identifier (if provided)
* `$context`: Context of the message (if specified)
* Any variables included in the interpolation

This design slightly changes how strings are compared directly, but ensures minimal impact on typing and code structure. To access the interpolated content, use `decodeMsg()`.

### Why an encoded string?

The alternative to using an encoded string would be for [`msg()`](/docs/react/reference/functions/msg) to return a custom object type containing the additional metadata. While this works for the encode/decode paradigm, it introduces issues when working with strict typing.

We concluded that the best way to minimise the impact of i18n in this scenario is simply to return a string that contains the metadata instead.

### Example

Original code without i18n:

```ts title="original.ts"
const name = 'John'
const message = `Hello, ${name}!`

if (message.length > 10) {
  console.log('The message is too long')
} else {
  console.log('The message is just the right length')
}
```

With [`msg()`](/docs/react/reference/functions/msg) and `decodeMsg()`:

```ts title="internationalized.ts"
import { msg, decodeMsg } from 'gt-next'

const name = 'John'
const message = msg('Hello, {name}!', { name })

if (decodeMsg(message).length > 10) {
  console.log('The message is too long')
} else {
  console.log('The message is just the right length')
}
```

## Other

You can also override parameters within the `gt()` function, even if they were already interpolated when calling [`msg()`](/docs/react/reference/functions/msg).

```tsx title="Page.tsx"
import { msg, useMessages } from 'gt-next'

const message = msg('Hello, {name}!', { name: 'John' })

export default function Page() {
  const m = useMessages()
  return <div>{m(message, { name: 'Jane' })}</div> // This will return "Hello, Jane!"
}
```

***

## Summary

This release focuses on making `gt-next` more developer-friendly while minimising the overhead of i18n. By eliminating the need to pass the `gt()` function through the call stack, the new [`msg()`](/docs/react/reference/functions/msg) function provides a cleaner, more intuitive way to translate strings and greatly simplifies the i18n process.

## Sitemap

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