Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions authors/jackie.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Jackie Chen
avatar: /static/avatars/jackie.png
occupation: Software Engineer
company: General Translation
email: jackie@generaltranslation.com
twitter: https://x.com/Some_Jackie
Expand Down
10 changes: 5 additions & 5 deletions blog/en-US/gt-next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tags: ['guide', 'internationalization', 'nextjs', 'gt-next']

**Internationalization (i18n) sucks. We're building a Next.js library, gt-next, to make it easier.** Today we're launching it in open beta.

``` copy
```bash copy
npm i gt-next
```

Expand Down Expand Up @@ -40,9 +40,9 @@ The goal with gt-next is to create an abundance mindset around translations. The
- Get an API key 🔐 on our [platform](https://generaltranslation.com)
- Read the [docs](https://generaltranslation.com/docs) 📄

### What you can do with gt-next
## What you can do with gt-next

#### Format variables and plurals
### Format variables and plurals

```javascript copy
import { T } from 'gt-next'
Expand All @@ -67,14 +67,14 @@ export default function Page() {
}
```

#### Use a developer API key to see translations locally
### Use a developer API key to see translations locally

```.env copy
GT_API_KEY="gtx-dev-cae62d6fe1e33bda603c9a2926ab0fb8"
GT_PROJECT_ID="abcdef12-3456-789a-bcd4-ef123456789a"
```

#### Support over 100 languages out of the box, with on-demand translation.
### Support over 100 languages out of the box, with on-demand translation.

![landing](/images/blogs/landing.png)

Expand Down
2 changes: 0 additions & 2 deletions blog/en-US/i18n-without-translation-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ authors: [jackie]
tags: ['guide', 'internationalization', 'nextjs', 'i18n', 'gt-next', 'translation-files', 'developer-experience']
---

import Video from '@/components/Video';

Everyone who's internationalized a JavaScript app knows the workflow. You install an i18n library, create an `en.json` file, pull every user-facing string out of your components, assign each one a key, and reference the key where the string used to be. Then you duplicate that JSON file for every language you support. `es.json`, `fr.json`, `ja.json`.

At first, it's fine. Thirty strings, three languages, 90 entries.
Expand Down
4 changes: 2 additions & 2 deletions devlog/en-US/gt-i18n_v0_1_0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Though `generaltranslation` is also a runtime-agnostic library, it is—by desig

## What's Included

- **[`msg()`](#)** - String registration and variable interpolation
- **[`mFallback()`](#)** and **[`gtFallback()`](#)** - Migration helpers for incremental adoption
- **`msg()`** - String registration and variable interpolation
- **`mFallback()`** and **`gtFallback()`** - Migration helpers for incremental adoption

---

Expand Down
4 changes: 2 additions & 2 deletions devlog/en-US/gt-next_v6_2_0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function Page() {
We deliberately kept `gt()` synchronous to match other i18n libraries.
The downside was a `two-step translation process`:

1. Register the text with the API.
2. Wait for a second render to display the translated result.
1. Register the text with the API.
2. Wait for a second render to display the translated result.

Now, thanks to the compiler, translatable content is scanned ahead of time and passed directly into `useGT()` or `getGT()` at compile time.
This means translations are immediately available at runtime — no page refreshes.
Expand Down
2 changes: 0 additions & 2 deletions devlog/en-US/gt-react_v10_15_0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ authors: [ernest]
tags: ['gt-react', 'derive', 'tagged-template', 'i18n']
---

import Video from '@/components/Video';

## The `declareStatic()` → `derive()` rename

This release is the first to ship with the new `derive()` name. Previously, this function was called `declareStatic()` and the JSX component was `<Static>`. In [PR #1062](https://github.com/generaltranslation/gt/pull/1062), both were renamed to `derive()` and `<Derive>` for clarity.
Expand Down
2 changes: 0 additions & 2 deletions devlog/en-US/gt-react_v10_19_0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ authors: [ernest]
tags: ['gt-react', 'browser', 'hot-reload', 'dev-experience', 'i18n']
---

import Video from '@/components/Video';

<Video src='https://assets.gtx.dev/devlogs/gt-react-browser-tx-hot-reload.mp4' />

## Overview
Expand Down
2 changes: 0 additions & 2 deletions devlog/en-US/react-core-linter_v0_1_0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ tags: ['react-core-linter', '0.1.0', 'eslint', 'linting', 'static-validation']

This plugin catches common implementation errors that we have seen in the wild.

import Video from '@/components/Video';

<Video src='https://assets.gtx.dev/docs/react-core-linter/web-0.1.0.mp4' />

## Installation
Expand Down
8 changes: 4 additions & 4 deletions docs/en-US/cli/stage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ There are a few key parameters:

| Parameter | Description |
|-----------------|--------------------------------------------------|
| `--dry-run` | This flag will cause the CLI to parse and validate your project, but will not communicate with the GT API. This is useful for validating your codebase.
| `--api-key` | Unless you are using `--dry-run`, you must provide a production API key.
| `--project-id` | Similarly, unless you are using `--dry-run`, you must provide a project ID.
| `--new, --locales <locales>` | Locales to translate your project into. These will be appended to the locales specified in your `gt.config.json` file.
| `--dry-run` | This flag will cause the CLI to parse and validate your project, but will not communicate with the GT API. This is useful for validating your codebase. |
| `--api-key` | Unless you are using `--dry-run`, you must provide a production API key. |
| `--project-id` | Similarly, unless you are using `--dry-run`, you must provide a project ID. |
| `--new, --locales <locales>` | Locales to translate your project into. These will be appended to the locales specified in your `gt.config.json` file. |

### Configuration file

Expand Down
2 changes: 0 additions & 2 deletions docs/en-US/core/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Overview of the generaltranslation library
The `generaltranslation` library serves as GT's core i18n library housing utility functions and classes for translation and formatting.
It is often used with framework packages like `gt-next` and `gt-react`, but can be used as a standalone library.

import Video from '@/components/Video';

<Video src='https://assets.gtx.dev/core-demo.mp4' />

```typescript title="index.ts"
Expand Down
10 changes: 5 additions & 5 deletions docs/en-US/core/locales.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Locales can be general or specific. For example:
- `zh-Hant` is Chinese, written with traditional characters
- `zh-Hant-HK` is Chinese, written with traditional characters, as spoken in Hong Kong

### Constructing locale codes
## Constructing locale codes

General Translation uses the [BCP 47 Language Tag](https://www.techonthenet.com/js/language_tags.php) standard to define locale codes.
BCP 47 Language Tags are the Internet Best Current Practices (BCP) standard for identifying languages in both spoken and written forms.
Expand All @@ -37,14 +37,14 @@ For example, `zh-Hant-HK` is:

Together, `zh-Hant-HK` means "Chinese, written in traditional characters, as spoken in Hong Kong".

### List of supported locales [#supported-locales]
## List of supported locales [#supported-locales]

See the [list of supported locales](/docs/platform/supported-locales) for a searchable list of all locales currently supported by General Translation.

Technically, the library supports any validly constructed tag, including private use codes with no widely recognized meaning.
However, the platform will only translate

### Equivalent locale tags
## Equivalent locale tags

Sometimes, multiple locale tags are functionally equivalent.
For example, you could write:
Expand All @@ -55,7 +55,7 @@ For example, you could write:
The General Translation libraries and platform usually don't distinguish between these equivalent codes,
since translating between them is impossible.

### Commonly used locale codes
## Commonly used locale codes

| Locale code | Language | Script | Region | Description |
|---------------|-------------|---------------------|-----------------|-----------------------------------------------|
Expand All @@ -77,7 +77,7 @@ since translating between them is impossible.
| `pt-BR` | Portuguese | ― | Brazil | Portuguese as spoken in Brazil |
| `it` | Italian | ― | ― | Italian |

### Next steps
## Next steps

- See our [List of Supported Locales](/docs/platform/supported-locales) to find the language tags available in General Translation.
- Refer to the official [IETF Language Tag Registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry)
Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/key-concepts/dynamic-content.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function Greeting(name) {
As far as translation goes this has two benefits:
1. You do not have to create a translation for every possible name.
* Using `<Var>`, we only generate one translation that essentially would look like this:
* \`¡Hola, $\{name\}!\`
* `¡Hola, ${name}!`
* If we do not use `<Var>`, we would have to perform an on-demand translation for every unique name:
* "¡Hola, Alice!", "¡Hola, Bob!", "¡Hola, Charlie!", "¡Hola, David!", ...
2. You also don't have to worry about the names themselves changing into a translated form of their name: (i.e. "¡Hola, Alicia!", "¡Hola, Roberto!", ...).
Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/locadex/auto-merge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Click the rule blocking auto-merge, then:
1. Click "Add Bypass"
2. Select "Locadex Agent" from the dropdown

![Add Bypass button with "Locadex Agent selected"](https://assets.gtx.dev/locadex-screenshots/auto-merge/add-bypass.png)
![Add Bypass button with "Locadex Agent" selected](https://assets.gtx.dev/locadex-screenshots/auto-merge/add-bypass.png)

### Step 4: Save changes

Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/locadex/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ It takes 5 minutes to install.

Locadex:

- Configures your project to use the gt-next i18n library
- Configures your project to use the `gt-next` i18n library
- Modifies your React components and strings to support multilingual content
- Translates your app into as many languages as you need
- Continuously internationalizes and translates as you push new content
Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/next/api/components/tx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The trade off is that there is a delay while waiting for an on-demand translatio
While loading, `<Tx>` will return undefined unless languages are similar (en-US vs en-GB), though this behavior can be customized with render settings.
If an error occurs, `<Tx>` will return the original content.

Our advice is to translate everything you can at build time using [`<T>`](/docs/next/api/components/t), [`getGT`](/docs/next/api/strings/use-gt), or [`useGT`](/docs/next/api/strings/use-gt),
Our advice is to translate everything you can at build time using [`<T>`](/docs/next/api/components/t), [`getGT`](/docs/next/api/strings/get-gt), or [`useGT`](/docs/next/api/strings/use-gt),
and only use on-demand translations, like `<Tx>` and [`tx`](/docs/next/api/strings/tx) when necessary.

Make sure to follow the [deployment guide here](/docs/next/tutorials/quickdeploy).
Expand Down
4 changes: 2 additions & 2 deletions docs/en-US/next/api/config/with-gt-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default withGTConfig(nextConfig, {
**Legacy**

`initGT` is the legacy way to configure the `gt-next` library. It returns a function callback which is then called on the `NextConfig` object.
The props for both functions are the same, with the exception that `withGTProps` requires `NextConfig` to also be passed in.
The props for both functions are the same, with the exception that `withGTConfig` requires `NextConfig` to also be passed in.
</Callout>

Use `withGTConfig` to:
Expand Down Expand Up @@ -275,7 +275,7 @@ If the translation takes longer than 8 seconds, the method will time out and ren
```json title="gt.config.json"
{
"defaultLocale": "en-US",
"locales": ["en-US", "es", "fr"],
"locales": ["en-US", "es", "fr"]
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/en-US/next/api/dictionary/use-translations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ For async components, see [`getTranslations`](/docs/next/api/dictionary/get-tran

### Returns

A translation function `d` that, given an id, will return the translated version of the corresponding entry
A translation function `t` that, given an id, will return the translated version of the corresponding entry

```jsx
(id: string, options?: DictionaryTranslationOptions) => string
Expand All @@ -53,7 +53,7 @@ A translation function `d` that, given an id, will return the translated version
| Name | Type | Description |
|-----------------------|--|-----------------------------------------------------------------------------|
| `id` | `string` | The id of the entry to be translated |
| `options?` | [`DictionaryTranslationOptions`](/docs/next/api/types/dictionary-translation-options) | Translation options to customize the behavior of `d`. |
| `options?` | [`DictionaryTranslationOptions`](/docs/next/api/types/dictionary-translation-options) | Translation options to customize the behavior of `t`. |

---

Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/next/api/helpers/get-locale.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ export default async function GetUserLocale() {

## Next steps

- Learn how to configure supported locales with [withGTConfig()](/docs/next/api/config/with-gt-config).
- Learn how to configure supported locales with [`withGTConfig()`](/docs/next/api/config/with-gt-config).
- Use [`isLocaleSupported`](/docs/next/api/helpers/is-locale-supported) to explicitly reject invalid locale route params.
2 changes: 1 addition & 1 deletion docs/en-US/next/api/strings/tx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The `tx` function translates strings at runtime.
This means that translations are performed live, so you can translate content that is only known at runtime.
The trade off is that there is a delay while waiting for an on-demand translation to load is significantly slower.

Our advice is to translate everything you can at build time using [`getGT`](/docs/next/api/strings/use-gt), [`useGT`](/docs/next/api/strings/use-gt), or [`<T>`](/docs/next/api/components/t),
Our advice is to translate everything you can at build time using [`getGT`](/docs/next/api/strings/get-gt), [`useGT`](/docs/next/api/strings/use-gt), or [`<T>`](/docs/next/api/components/t),
and only use on-demand translations, like `tx` and [`<Tx>`](/docs/next/api/components/tx), when necessary.

Make sure to follow the [deployment guide here](/docs/next/tutorials/quickdeploy).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See [`tx`](/docs/next/api/strings/tx) for translating strings with dynamic conte

### Passing variables

In order to pass a variable to the dictionary entry, we need to do two things: (1) add a variable to the entry and (2) reference said variable in the [`d`](/docs/next/api/strings/use-gt) invocation.
In order to pass a variable to the dictionary entry, we need to do two things: (1) add a variable to the entry and (2) reference said variable in the `t` invocation.

First, we add a variable to the dictionary entry with the following syntax: `{username}`.
`username` is the name of the variable.
Expand Down
1 change: 1 addition & 0 deletions docs/en-US/next/api/types/runtime-translation-options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ This is used with the [`tx`](/docs/next/api/strings/tx) function.
| ---- | ----------- |
| `[variable]` | Variables are passed as top-level keys in the options object. The key names correspond to placeholders in the string (e.g., `{username}`). |
| `$locale` | Specify a locale for the translation. Will default to browser's most preferred locale that is supported by your app. |
| `$context` | Provide context for the content to guide translation. |
| `$maxChars` | Limit the character count of the translation. The library strictly enforces this limit. |


Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/next/guides/languages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Changing Languages
description: How to configure and switch between languages in your Next.js app
---

Language switching allows users to change their preferred locale for your application's content. GT Next provides several approaches from simple programmatic switching to full URL-based routing with middleware.
Language switching allows users to change their preferred locale for your application's content. `gt-next` provides several approaches from simple programmatic switching to full URL-based routing with middleware.

## Available methods

Expand Down
4 changes: 2 additions & 2 deletions docs/en-US/next/guides/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ You'll never have to wait for translations again.

1. Fully migrate your entire project to `gt-next`, and remove the old i18n library.
2. Fully migrate your project, but keep using dictionaries from the old i18n library.
2. Keep using the old i18n library for now, and only migrate part of your project to `gt-next`.
3. Keep using the old i18n library for now, and only migrate part of your project to `gt-next`.

For more details on each option, see the [migration strategies](#strategies) section.
</Step>
Expand Down Expand Up @@ -221,7 +221,7 @@ We offer it as a way to make migration easier, but we don't recommend using it f

### 3. Using AI

If you are using AI to help you migrate your project, we have a `LLMs.txt` and `LLMs-full.txt` available at:
If you are using AI to help you migrate your project, we have an `LLMs.txt` and `LLMs-full.txt` available at:

- [LLMs.txt](/llms.txt)
- [LLMs-full.txt](/llms-full.txt)
Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/next/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ That's it — your app is now multilingual. 🎉
<T context="the technology company">Apple</T>
```

Both `<T>`, `useGT()`, and `getGT()` support the `context` option.
`<T>`, `useGT()`, and `getGT()` all support the `context` option.
</Accordion>
</Accordions>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ npm i gt-next
```

### Set up your environment
Create a `.env` file in the root of your project and add your api key and project id.
Create a `.env` file in the root of your project and add your API key and project ID.

```dotenv copy
GT_API_KEY="YOUR_GT_API_KEY"
Expand Down
6 changes: 3 additions & 3 deletions docs/en-US/next/tutorials/examples/next-speedrun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ npm i gt
## Step 3: Add your environment variables.

Navigate to the [Dashboard](https://generaltranslation.com/en-US/signin).
Go to the Dev Api Keys page on the nav bar and create a new API key and Project ID.
Go to the Dev API Keys page on the nav bar and create a new API key and Project ID.
Then add them to your `.env` file.

```bash copy
Expand Down Expand Up @@ -116,7 +116,7 @@ If you have set up everything correctly, you should see your app in the language
**Browser Cookies**

Check your browser's cookies for your app.
General translation uses cookies to store the user's language preference.
General Translation uses cookies to store the user's language preference.
The cookie is called `generaltranslation.locale`, and all you need to do is delete it.
It will be under `localhost:3000`.
Then, just double-check you are using the desired preferred language and then
Expand All @@ -139,5 +139,5 @@ If you have set up everything correctly, you should see your app in the language
* If translation is not working when you change your language, check your browser's cookies.

## Next steps
* Star our GitHub repo [gt-next](https://github.com/General-Translation/gt-next).
* Star our GitHub repo [`gt-next`](https://github.com/General-Translation/gt-next).
* Set up [Right to Left language support](/docs/next/guides/rtl).
2 changes: 1 addition & 1 deletion docs/en-US/node/guides/strings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gt('{city} weather: {temp}°F', { city: 'Tokyo', temp: 72 });

## Pre-registered strings with `msg()` / `getMessages()`

Use [`msg()`](/docs/node/api/get-messages) to register strings at module scope — outside of any request handler. Then use [`getMessages()`](/docs/node/api/get-messages) inside handlers to resolve them for the current locale:
Use [`msg()`](/docs/node/api/strings/msg) to register strings at module scope — outside of any request handler. Then use [`getMessages()`](/docs/node/api/get-messages) inside handlers to resolve them for the current locale:

```js title="messages.js"
import { msg } from 'gt-node';
Expand Down
2 changes: 0 additions & 2 deletions docs/en-US/react-core-linter/guides/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ description: Quickstart guide for the React Core Linter
This is an ESLint plugin designed to be used with any of our i18n libraries, `gt-react`, `gt-next`, or `gt-react-native`.
It checks for common implementation errors and offers fixes.

import Video from '@/components/Video';

<Video src='https://assets.gtx.dev/docs/react-core-linter/web-0.1.0.mp4' />

## Installation
Expand Down
2 changes: 0 additions & 2 deletions docs/en-US/react-core-linter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ description: ESLint plugin for GT React libraries

It checks for issues like dynamic content inside `<T>` components and dynamic strings in translation functions, and offers autofixes.

import Video from '@/components/Video';

<Video src='https://assets.gtx.dev/docs/react-core-linter/web-0.1.0.mp4' />

## Rules
Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/react-core-linter/rules/static-string.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Ensures that translation functions like [`gt`](/docs/react/api/strings/use-gt) a

### staticStringRequired

Registration functions can only accept static strings.
Translation functions can only accept static strings.

#### ❌ Incorrect

Expand Down
Loading
Loading