Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
27c1f42
color and og image gen
fernando-aviles Sep 22, 2025
6b9b6fe
rearrange the locadex section, add deployement
SamEggert Sep 24, 2025
991246e
docs technical changes
fernando-aviles Sep 24, 2025
686aeef
lint
fernando-aviles Sep 24, 2025
8cfe67a
comments
fernando-aviles Sep 24, 2025
15a304c
fixing serve rindex
fernando-aviles Sep 24, 2025
286510d
cleaning up types
fernando-aviles Sep 24, 2025
fc865df
vercel build fix
fernando-aviles Sep 24, 2025
01d2f6c
fix route
fernando-aviles Sep 24, 2025
5e75440
export fix
fernando-aviles Sep 24, 2025
24675cf
param fix
fernando-aviles Sep 24, 2025
31359be
search bar style
fernando-aviles Sep 24, 2025
aa3ed1b
lint
fernando-aviles Sep 24, 2025
f9650c8
feat: add config page, and some minor i18n fixes
ErnestM1234 Sep 24, 2025
fcdbfc8
fix: configuration description
ErnestM1234 Sep 24, 2025
41b2eb1
remove search echo
fernando-aviles Sep 24, 2025
58bffde
lint
fernando-aviles Sep 24, 2025
9b18629
fix: redirect changelog to github
ErnestM1234 Sep 24, 2025
e483ff1
cleanup
fernando-aviles Sep 24, 2025
cabf3a3
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 24, 2025
a95008f
platform
archie-mckenzie Sep 25, 2025
19b3277
push what i have for locadex
SamEggert Sep 25, 2025
6e8bec3
feat: core docs first draft
ErnestM1234 Sep 25, 2025
47c8cf2
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 25, 2025
244a0f5
fix: update locale pages
ErnestM1234 Sep 25, 2025
3ea8dbe
chore: update docs
ErnestM1234 Sep 25, 2025
774fb80
Merge branch 'main' into gt/docs-rewrite-20250922
ErnestM1234 Sep 25, 2025
1acd16e
feat: add demo video
ErnestM1234 Sep 25, 2025
e8f5107
feat: demo vid
ErnestM1234 Sep 25, 2025
5e5e160
fix: remove jsx translation
ErnestM1234 Sep 25, 2025
475b380
fix: bump gtx-cli version
ErnestM1234 Sep 25, 2025
349cd13
fix: demo
ErnestM1234 Sep 25, 2025
13f4dbc
fix: build error
ErnestM1234 Sep 25, 2025
479382a
reworked next guides pt1
fernando-aviles Sep 25, 2025
b487886
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 25, 2025
701b71c
feat: quickstart
ErnestM1234 Sep 25, 2025
91a56b9
chore: merge main
ErnestM1234 Sep 25, 2025
c590983
advanced integration pt1
fernando-aviles Sep 25, 2025
1d59da8
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 25, 2025
d28b92c
feat: constructor page
ErnestM1234 Sep 25, 2025
dab788a
merge
ErnestM1234 Sep 25, 2025
312d1da
feat: setConfig docs
ErnestM1234 Sep 26, 2025
efae918
feat: format datetime
ErnestM1234 Sep 26, 2025
2a949e9
eat: format message
ErnestM1234 Sep 26, 2025
9921feb
advanced pt2
fernando-aviles Sep 26, 2025
3ffe95c
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 26, 2025
079c827
fix: format num
ErnestM1234 Sep 26, 2025
61f6f99
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 26, 2025
9410216
feat: gt.determineLocale
ErnestM1234 Sep 26, 2025
b50fb15
feat: getLocaleDirection
ErnestM1234 Sep 26, 2025
6f00be9
feat: getLocaleEmoji
ErnestM1234 Sep 26, 2025
e0785a5
feat: getLocaleName
ErnestM1234 Sep 26, 2025
5c2c259
get locale properties
ErnestM1234 Sep 26, 2025
7890183
reformat sidebar and add locadex page
fernando-aviles Sep 26, 2025
5fed9fc
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 26, 2025
50dba14
feat: getRegionProperties
ErnestM1234 Sep 26, 2025
ab1b86f
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 26, 2025
4621469
feat: getRegionProperties
ErnestM1234 Sep 26, 2025
85b2fe8
feat: isSameDialect
ErnestM1234 Sep 26, 2025
fee8dc4
fix: rebase this fernando
ErnestM1234 Sep 26, 2025
acb2f4b
feat: isSameLanguage
ErnestM1234 Sep 26, 2025
278fa62
feat: isSupersetLocale
ErnestM1234 Sep 26, 2025
1d36e14
feat: is valid locale
ErnestM1234 Sep 26, 2025
82a7b3a
fix: rebase for fernando <3
ErnestM1234 Sep 26, 2025
d1c0d1c
feat: requires translation
ErnestM1234 Sep 26, 2025
42dd7cb
fix: resolveAliasLocale
ErnestM1234 Sep 26, 2025
849eb63
remove migration
fernando-aviles Sep 26, 2025
22c23b8
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 26, 2025
c49dea1
feat: resolve canonical locale
ErnestM1234 Sep 26, 2025
450abfe
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 26, 2025
f9ea529
next quikcstart
fernando-aviles Sep 26, 2025
a400598
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 26, 2025
507eca8
fix: resolveCanonicalLocale
ErnestM1234 Sep 26, 2025
40f26b3
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 26, 2025
d1bfe29
fix: standardizeLocale
ErnestM1234 Sep 26, 2025
32447f3
fix: checkFileTranslation
ErnestM1234 Sep 26, 2025
ae97d1d
fix: check setup status
ErnestM1234 Sep 26, 2025
966b9a6
next overview
fernando-aviles Sep 26, 2025
42cb0e4
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 26, 2025
fba32c1
build command
fernando-aviles Sep 26, 2025
e2cee2f
build command
fernando-aviles Sep 26, 2025
9e682cc
next/vars
fernando-aviles Sep 26, 2025
280a57f
fix: downloadFileBatch
ErnestM1234 Sep 26, 2025
202b454
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 26, 2025
055f69c
fix: downloadFileBatch
ErnestM1234 Sep 26, 2025
f3f4d6c
fix: checkFileTranslations
ErnestM1234 Sep 26, 2025
795aed3
react guides
fernando-aviles Sep 26, 2025
b334245
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 26, 2025
c7d7fb3
fix: downloadTranslatedFile
ErnestM1234 Sep 26, 2025
51420f1
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 26, 2025
62b2a64
fix: enqueue files
ErnestM1234 Sep 26, 2025
f05f34e
fix: getProjectData
ErnestM1234 Sep 26, 2025
69f6b7a
fix: query source file
ErnestM1234 Sep 26, 2025
69b33e0
fix: set up project
ErnestM1234 Sep 26, 2025
ebddd99
fix: translate many
ErnestM1234 Sep 26, 2025
5574cc4
merging technical changes from main
fernando-aviles Sep 26, 2025
b525f9b
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
fernando-aviles Sep 26, 2025
d4baa99
merging from main
fernando-aviles Sep 26, 2025
ecbf2d7
fix: uploadSourceFiles
ErnestM1234 Sep 27, 2025
caa8061
Merge branch 'gt/docs-rewrite-20250922' of https://github.com/general…
ErnestM1234 Sep 27, 2025
d50c206
feat: MAJOR IMPROVEMENTS
ErnestM1234 Sep 27, 2025
9658684
fix: major unimprovements
ErnestM1234 Sep 27, 2025
1fb3ac2
fix: standalone format
ErnestM1234 Sep 27, 2025
71996ad
fix: standalone apis
ErnestM1234 Sep 27, 2025
cda18ff
fix: types
ErnestM1234 Sep 27, 2025
3cc0183
fix: link
ErnestM1234 Sep 27, 2025
2f80a0d
fix: config page
ErnestM1234 Sep 27, 2025
3bb0304
fix: quickstart
ErnestM1234 Sep 27, 2025
516ad9a
chore: cleanup
ErnestM1234 Sep 27, 2025
d941533
fix: tiny
ErnestM1234 Sep 27, 2025
c5d42a9
fix: remove speedrun
ErnestM1234 Sep 27, 2025
d839f2e
add back guides from main
SamEggert Sep 29, 2025
2c26fa1
add doc on how to "Auto-merge Pull Requests"
SamEggert Sep 29, 2025
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This open-source repo contains internationalization libraries for React framewor

## Add the `<T>` component and see translations as you code:

![Demo](./apps/docs/public/live_translations.gif)
![Demo](./apps/docs/public/demo.gif)

## Features

Expand Down
9 changes: 8 additions & 1 deletion apps/docs/app/[locale]/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import SupportedLocales from '@/components/SupportedLocales';
import { InlineTOC } from 'fumadocs-ui/components/inline-toc';
import { Rate } from '@/components/rate';
import { Metadata } from 'next';
import { getLocale } from 'gt-next/server';
import { Mermaid } from '@/components/mdx/mermaid';
import Video from '@/components/Video';

const customMdxComponents = {
a: (props: React.ComponentProps<'a'>) => (
Expand All @@ -46,11 +49,15 @@ const customMdxComponents = {
LogoCardContent,
AllLogoCards,
SupportedLocales,
Mermaid,
Video,
};
export default async function Page(props: {
params: Promise<{ slug?: string[]; locale: string }>;
}) {
const { slug, locale } = await props.params;
const { slug } = await props.params;
const locale = await getLocale();

const page = source.getPage(slug, locale);
if (!page) notFound();

Expand Down
47 changes: 22 additions & 25 deletions apps/docs/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@ import { DocsLayout } from 'fumadocs-ui/layouts/notebook';
import type { ReactNode } from 'react';
import { baseOptions } from '@/app/[locale]/layout.config';
import { source } from '@/lib/source';
import { GTProvider } from 'gt-next';
import { GTProvider, T } from 'gt-next';
import { getLocaleProperties } from 'generaltranslation';
import { SiGithub } from '@icons-pack/react-simple-icons';
import { PostHogProvider } from '@/components/analytics/PostHogProvider';
import AnalyticsBanner from '@/components/analytics/AnalyticsBanner';
import SearchDialog from '@/components/SearchDialog';
import PrefetchSearchIndex from '@/components/PrefetchSearchIndex';
import { getGT, getLocale, getLocales } from 'gt-next/server';

const inter = Inter({
subsets: ['latin'],
});

export function generateMetadata(): Metadata {
export async function generateMetadata(): Promise<Metadata> {
const gt = await getGT();
return {
title: 'Docs — General Translation',
description:
'Documentation for the General Translation internationalization platform',
title: gt('Docs — General Translation'),
description: gt(
'Documentation for the General Translation internationalization platform'
),
icons: {
icon: [
{
Expand All @@ -38,15 +41,15 @@ export function generateMetadata(): Metadata {
],
},
keywords: [
'translation',
'localization',
'l10n',
'i18n',
'internationalization',
'automate',
'next.js',
'nextjs',
'react',
gt('translation'),
gt('localization'),
gt('internationalization'),
gt('l10n', { context: 'localization' }),
gt('i18n', { context: 'internationalization' }),
gt('automate'),
gt('next.js'),
gt('nextjs'),
gt('react'),
],
};
}
Expand All @@ -55,16 +58,10 @@ function capitalize(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}

export default async function Layout({
children,
params,
}: {
children: ReactNode;
params: Promise<{ locale: string }>;
}) {
const { locale } = await params;
export default async function Layout({ children }: { children: ReactNode }) {
const locale = await getLocale();
const options = await baseOptions(locale);
const locales = ['en', 'zh', 'de', 'fr', 'es', 'ja'].map((locale) => ({
const locales = getLocales().map((locale) => ({
name: capitalize(getLocaleProperties(locale, locale).languageName),
locale: locale,
}));
Expand Down Expand Up @@ -118,7 +115,7 @@ export default async function Layout({
},
},
banner: (
<>
<T>
<a
href="https://github.com/generaltranslation/gt"
target="_blank"
Expand All @@ -131,7 +128,7 @@ export default async function Layout({
</h3>
</div>
</a>
</>
</T>
),
}}
tree={source.pageTree[locale]}
Expand Down
4 changes: 1 addition & 3 deletions apps/docs/components/Video.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { BASE_URL } from '@/lib/constants';

export default function Video({ src }: { src: string }) {
return <video src={BASE_URL + src} loop controls className="rounded-lg" />;
return <video src={src} loop controls autoPlay className="rounded-lg" />;
}
60 changes: 60 additions & 0 deletions apps/docs/components/mdx/mermaid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use client';

import { use, useEffect, useId, useState } from 'react';
import { useTheme } from 'next-themes';

export function Mermaid({ chart }: { chart: string }) {
const [mounted, setMounted] = useState(false);

useEffect(() => {
setMounted(true);
}, []);

if (!mounted) return;
return <MermaidContent chart={chart} />;
}

const cache = new Map<string, Promise<unknown>>();

function cachePromise<T>(
key: string,
setPromise: () => Promise<T>
): Promise<T> {
const cached = cache.get(key);
if (cached) return cached as Promise<T>;

const promise = setPromise();
cache.set(key, promise);
return promise;
}

function MermaidContent({ chart }: { chart: string }) {
const id = useId();
const { resolvedTheme } = useTheme();
const { default: mermaid } = use(
cachePromise('mermaid', () => import('mermaid'))
);

mermaid.initialize({
startOnLoad: false,
securityLevel: 'loose',
fontFamily: 'inherit',
themeCSS: 'margin: 1.5rem auto 0;',
theme: resolvedTheme === 'dark' ? 'dark' : 'default',
});

const { svg, bindFunctions } = use(
cachePromise(`${chart}-${resolvedTheme}`, () => {
return mermaid.render(id, chart.replaceAll('\\n', '\n'));
})
);

return (
<div
ref={(container) => {
if (container) bindFunctions?.(container);
}}
dangerouslySetInnerHTML={{ __html: svg }}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Install the `gtx-cli` tool in your project.
<Tabs items={['npm', 'yarn', 'bun', 'pnpm']}>
<Tab value="npm">
```bash
npm i --save-dev gtx-cli
npm i gtx-cli
```
</Tab>
<Tab value="yarn">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/en/cli/formats/json.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Install the `gtx-cli` tool in your project.
<Tabs items={['npm', 'yarn', 'bun', 'pnpm']}>
<Tab value="npm">
```bash
npm i --save-dev gtx-cli
npm i gtx-cli
```
</Tab>
<Tab value="yarn">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/en/cli/formats/mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Install the `gtx-cli` tool in your project.
<Tabs items={['npm', 'yarn', 'bun', 'pnpm']}>
<Tab value="npm">
```bash
npm i --save-dev gtx-cli
npm i gtx-cli
```
</Tab>
<Tab value="yarn">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Install the `gtx-cli` tool in your project.
<Tabs items={['npm', 'yarn', 'bun', 'pnpm']}>
<Tab value="npm">
```bash
npm i --save-dev gtx-cli
npm i gtx-cli
```
</Tab>
<Tab value="yarn">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/en/cli/formats/ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Install the `gtx-cli` tool in your project.
<Tabs items={['npm', 'yarn', 'bun', 'pnpm']}>
<Tab value="npm">
```bash
npm i --save-dev gtx-cli
npm i gtx-cli
```
</Tab>
<Tab value="yarn">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/en/cli/reference/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To install the CLI tool, run the following command:
<Tabs items={['npm', 'yarn', 'bun', 'pnpm']}>
<Tab value="npm">
```bash
npm i --save-dev gtx-cli
npm i gtx-cli
```
</Tab>
<Tab value="yarn">
Expand Down
123 changes: 123 additions & 0 deletions apps/docs/content/docs/en/core/class/constructor.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
title: GT Constructor
description: API Reference for the GT class constructor
---

## Overview

The `GT` constructor creates a new instance of the General Translation class, which provides access to all translation, formatting, and locale functionality.

```typescript
import { GT } from 'generaltranslation';

const gt = new GT({
apiKey: 'your-api-key',
projectId: 'your-project-id',
sourceLocale: 'en',
targetLocale: 'es'
});
```

The constructor will automatically check the environment for `GT_API_KEY` and `GT_PROJECT_ID` environment variables, so you can omit them from the constructor parameters.
Additionally, it will validate all provided locale codes.

---

## Reference

### Parameters

<TypeTable
type={{
"params": {
type: 'GTConstructorParams',
optional: true,
default: '{}',
}
}}
/>

The `GTConstructorParams` object supports the following properties:

| Property | Type | Optional | Description |
|----------|------|----------|-------------|
| `apiKey` | `string` | ✓ | Production API key for translation service |
| `devApiKey` | `string` | ✓ | Development API key (takes precedence in development) |
| `projectId` | `string` | ✓ | Unique project identifier |
| `sourceLocale` | `string` | ✓ | Default source locale for translations |
| `targetLocale` | `string` | ✓ | Default target locale for translations |
| `locales` | `string[]` | ✓ | Array of supported locale codes |
| `baseUrl` | `string` | ✓ | Custom API base URL (for enterprise deployments) |
| `customMapping` | `CustomMapping` | ✓ | Custom locale code mappings and definitions |

### Returns

A new `GT` class instance with all translation and locale methods available.

---


## Examples

### Basic Usage

```typescript
import { GT } from 'generaltranslation';

// Minimal setup - uses environment variables
const gt = new GT();
```

### With API Credentials

```typescript
const gt = new GT({
projectId: 'my-project-id',
apiKey: 'my-api-key',
targetLocale: 'fr'
});
```

### With Custom Locale Mapping
A custom mapping can be provided.
This lets the user (1) use aliases for locale codes which, (2) can override the standard BCP 47 validation, and (3) override the standard BCP 47 locale information.

For example, say you wanted to use `cn` as an alias for `zh`.
Because the General Translation API does not support `cn`, you must specify a custom mapping.

```typescript
const gt = new GT({
projectId: 'my-project-id',
apiKey: 'my-api-key',
targetLocale: 'es',
customMapping: {
'cn': { code: 'zh' }
}
});
```

You can do other things with custom mappings, such as add custom names, emojis, etc.

```typescript
const gt = new GT({
projectId: 'my-project-id',
apiKey: 'my-api-key',
targetLocale: 'es',
customMapping: { 'en-US': { name: 'Mandarin', emoji: '🇫🇷' } }
});
```

---

## Notes

- All parameters are optional, but API operations will require `apiKey` and `projectId`
- The constructor validates all locale codes immediately, throwing errors for invalid codes
- Custom mappings take precedence over standard BCP 47 validation

## Next Steps

- Configure your instance with [`setConfig()`](/docs/core/class/setConfig)
- Start translating with [`translate()`](/docs/core/class/methods/translation/translate)
- Learn about [`GTConstructorParams` type](/docs/core/types/GTConstructorParams)
- Explore locale utilities [`getLocaleName()`](/docs/core/class/methods/locales/getLocaleName)
8 changes: 8 additions & 0 deletions apps/docs/content/docs/en/core/class/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"title": "GT Class",
"pages": [
"./constructor",
"./setConfig",
"./methods"
]
}
Loading
Loading