Skip to content
Merged
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
23 changes: 23 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
validate:
name: Check for unsafe patterns
Expand All @@ -25,3 +28,23 @@ jobs:
echo "::error::MDX files must not contain javascript: URLs."
exit 1
fi

validate-links:
name: Validate internal links
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
working-directory: scripts
run: npm ci

- name: Validate links
working-directory: scripts
run: npx tsx validate-links.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/node_modules/
2 changes: 1 addition & 1 deletion blog/en-US/plurals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Although developers often think that i18n libraries are only for multilingual in
they can be very useful for plural and variable formatting even in single-language applications.
Under the hood, most i18n libraries use JavaScript's built-in `Intl.PluralRules` API to determine the correct plural form for any language.

There are plenty of React i18n libraries, including ours, [gt-react](/docs) (or [gt-next](/docs) if you're using Next.js).
There are plenty of React i18n libraries, including ours, [gt-react](/docs/react) (or [gt-next](/docs/next) if you're using Next.js).
Displaying an English plural using gt-react is simple:

```jsx
Expand Down
66 changes: 0 additions & 66 deletions docs-templates/api/helpers/get-locale-direction.mdx

This file was deleted.

77 changes: 0 additions & 77 deletions docs-templates/api/helpers/get-locale-properties.mdx

This file was deleted.

53 changes: 0 additions & 53 deletions docs-templates/api/helpers/get-locales.mdx

This file was deleted.

48 changes: 0 additions & 48 deletions docs-templates/api/helpers/get-region.mdx

This file was deleted.

5 changes: 2 additions & 3 deletions docs-templates/api/helpers/use-default-locale.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ This locale represents the fallback language for your app and is typically used
Ensure your app is wrapped in a [`<GTProvider>`](__DOCS_PATH__/api/components/gtprovider).
</Callout>

See [`withGTConfig`](__DOCS_PATH__/api/config/with-gt-config) for configuration.
If no default locale is specified in [`withGTConfig`](__DOCS_PATH__/api/config/with-gt-config), it defaults to `'en-US'`.
For server-side, see [`getDefaultLocale`](__DOCS_PATH__/api/helpers/get-default-locale).
See [`gt.config.json`](__DOCS_PATH__/api/config/gt-config-json) for configuration.
If no default locale is specified, it defaults to `'en-US'`.

## Reference

Expand Down
5 changes: 1 addition & 4 deletions docs-templates/api/helpers/use-locale-direction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The `useLocaleDirection` hook retrieves the text direction (`'ltr'` or `'rtl'`)
Ensure your app is wrapped in a [`<GTProvider>`](__DOCS_PATH__/api/components/gtprovider).
</Callout>

For server-side usage, see [`getLocaleDirection`](__DOCS_PATH__/api/helpers/get-locale-direction).

## Reference

Expand Down Expand Up @@ -58,10 +57,8 @@ export default function SpecificDirection() {

## Notes

- Unlike the server-side [`getLocaleDirection`](__DOCS_PATH__/api/helpers/get-locale-direction), this hook is always synchronous.
- This hook is always synchronous.
- Useful for setting the `dir` attribute on elements for RTL support.

## Next steps

- Learn about RTL support in the [right-to-left guide](__DOCS_PATH__/guides/rtl).
- See [`getLocaleDirection`](__DOCS_PATH__/api/helpers/get-locale-direction) for the server-side equivalent.
2 changes: 0 additions & 2 deletions docs-templates/api/helpers/use-locale-properties.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The `useLocaleProperties` hook returns metadata about a given locale, including
Ensure your app is wrapped in a [`<GTProvider>`](__DOCS_PATH__/api/components/gtprovider).
</Callout>

For server-side usage, see [`getLocaleProperties`](__DOCS_PATH__/api/helpers/get-locale-properties).

## Reference

Expand Down Expand Up @@ -77,5 +76,4 @@ export default function LocaleInfo() {

## Next steps

- See [`getLocaleProperties`](__DOCS_PATH__/api/helpers/get-locale-properties) for the server-side equivalent.
- Learn more about [locale codes](/docs/core/locales).
4 changes: 1 addition & 3 deletions docs-templates/api/helpers/use-locales.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The `useLocales` hook retrieves the list of supported locales from the [`<GTProv
Ensure your app is wrapped in a [`<GTProvider>`](__DOCS_PATH__/api/components/gtprovider).
</Callout>

For server-side usage, see [`getLocales`](__DOCS_PATH__/api/helpers/get-locales).

## Reference

Expand Down Expand Up @@ -47,9 +46,8 @@ export default function LocaleList() {
## Notes

- The `useLocales` hook relies on the [`<GTProvider>`](__DOCS_PATH__/api/components/gtprovider) to access the context. Ensure your app is wrapped with a provider at the root level.
- `useLocales` is client-side only. For server components, use [`getLocales`](__DOCS_PATH__/api/helpers/get-locales).
- `useLocales` is client-side only.

## Next steps

- Learn how to configure supported locales in [`gt.config.json`](__DOCS_PATH__/api/config/gt-config-json).
- See [`getLocales`](__DOCS_PATH__/api/helpers/get-locales) for the server-side equivalent.
2 changes: 0 additions & 2 deletions docs-templates/api/helpers/use-region.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The `useRegion` hook retrieves the user's currently selected region from the [`<
Ensure your app is wrapped in a [`<GTProvider>`](__DOCS_PATH__/api/components/gtprovider).
</Callout>

For server-side usage, see [`getRegion`](__DOCS_PATH__/api/helpers/get-region).

## Reference

Expand Down Expand Up @@ -45,6 +44,5 @@ export default function RegionDisplay() {

## Next steps

- See [`getRegion`](__DOCS_PATH__/api/helpers/get-region) for the server-side equivalent.
- Use [`<RegionSelector>`](__DOCS_PATH__/api/components/region-selector) to let users choose their region.
- Use [`useRegionSelector`](__DOCS_PATH__/api/helpers/use-region-selector) to build a custom region selector.
3 changes: 1 addition & 2 deletions docs-templates/api/strings/msg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The `msg` function is a function that marks and encodes strings for translation.
const encodedString = msg('Hello, world!');
```

The encoded string should be passed to the [`useMessages`](__DOCS_PATH__/api/strings/use-messages) hook or [`getMessages`](__DOCS_PATH__/api/strings/get-messages) function to retrieve translations.
The encoded string should be passed to the [`useMessages`](__DOCS_PATH__/api/strings/use-messages) hook to retrieve translations.

<Callout>
**Encoding:**
Expand Down Expand Up @@ -149,4 +149,3 @@ export default function TranslateGreeting() {

## Next steps
* See [`useMessages`](__DOCS_PATH__/api/strings/use-messages) for translating strings.
* See [`getMessages`](__DOCS_PATH__/api/strings/get-messages) for translating strings in async server-side components.
2 changes: 1 addition & 1 deletion docs-templates/guides/shared-strings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function MyComponent() {

## Getting original strings with decodeMsg

Sometimes you need to access the original string without translation, such as for logging, debugging, or comparisons. Use [`decodeMsg`](__DOCS_PATH__/api/strings/msg#decodemsg) to extract the original text:
Sometimes you need to access the original string without translation, such as for logging, debugging, or comparisons. Use [`decodeMsg`](__DOCS_PATH__/api/strings/msg) to extract the original text:

```tsx
import { decodeMsg } from '__PACKAGE_NAME__';
Expand Down
Loading
Loading