Skip to content

Commit

Permalink
test i18n at top level (#887)
Browse files Browse the repository at this point in the history
* test i18n at top level

* es to docs

* test

* push introduction instead
  • Loading branch information
Rishi Raj Jain committed Jan 20, 2024
1 parent c062cc4 commit 19cc44f
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 116 deletions.
23 changes: 1 addition & 22 deletions website/middleware.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
import { NextResponse } from 'next/server';
// import { withLocales } from 'nextra/locales';

// export const middleware = (request: NextRequest) => {
// const newRequestObject = {
// ...request,
// url: new URL('/docs', request.url),
// };

// return withLocales((request: NextRequest) => {
// return NextResponse.rewrite(new URL('/docs', request.url));
// })(newRequestObject);
// };

// // This function can be marked `async` if using `await` inside

// // See "Matching Paths" below to learn more
// export const config = {
// matcher: '/docs/:path*',
// };

import { locales } from 'nextra/locales';

export const middleware = (request) => {
const { nextUrl } = request;

// The middleware must not handle dynamic routes.
if (nextUrl.pathname.startsWith('/ai')) {
// The middleware must not handle dynamic routes.
return;
}

Expand Down
11 changes: 10 additions & 1 deletion website/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ const withNextra = nextra({
const nextConfig = {
transpilePackages: ['react-tweet'],
i18n: {
locales: ['en-US', 'zh-CN', 'de-DE'],
locales: ['en-US', 'es-ES', 'ru'],
defaultLocale: 'en-US',
},
async redirects() {
return [
{
source: '/docs.([a-zA-Z-]+)',
destination: '/docs/introduction',
statusCode: 302,
},
];
},
};

// eslint-disable-next-line import/no-default-export -- Next.js requires default export
Expand Down
76 changes: 76 additions & 0 deletions website/pages/_meta.en-US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"index": {
"title": "Introduction",
"type": "page",
"display": "hidden"
},
"docs": {
"type": "page",
"title": "Docs"
},
"remote": {
"type": "page",
"title": "Remote",
"href": "/remote/4423220"
},
"about": {
"type": "menu",
"title": "About",
"items": {
"contributors": {
"title": "Contributors",
"href": "https://github.com/vercel/swr/graphs/contributors",
"newWindow": true
},
"team": {
"title": "Team"
},
"acknowledgement": {
"title": "Acknowledgement"
},
"a-page": {
"title": "A Page"
},
"changelog": {
"title": "Changelog"
}
}
},
"examples": {
"type": "page",
"title": "Examples",
"theme": {
"layout": "full"
}
},
"blog": {
"type": "page",
"title": "Blog",
"theme": {
"sidebar": false,
"toc": true,
"breadcrumb": false,
"typesetting": "article"
}
},
"nextra_link": {
"type": "page",
"title": "Nextra ↗",
"href": "https://github.com/shuding/nextra",
"newWindow": true
},
"404": {
"type": "page",
"theme": {
"timestamp": false,
"typesetting": "article"
}
},
"500": {
"type": "page",
"theme": {
"timestamp": false,
"typesetting": "article"
}
}
}
19 changes: 19 additions & 0 deletions website/pages/_meta.es-ES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"index": {
"title": "Introducción",
"type": "page",
"display": "hidden"
},
"docs": {
"title": "Docs",
"type": "page"
},
"examples": {
"title": "Ejemplos",
"type": "page"
},
"blog": {
"title": "Blog",
"type": "page"
}
}
73 changes: 0 additions & 73 deletions website/pages/_meta.json

This file was deleted.

26 changes: 26 additions & 0 deletions website/pages/_meta.ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"index": {
"title": "Введение",
"type": "page",
"display": "hidden"
},
"docs": {
"title": "Документация",
"type": "page"
},
"examples": {
"title": "Примеры",
"type": "page"
},
"blog": {
"title": "Блог",
"type": "page",
"theme": {
"timestamp": true,
"sidebar": false,
"toc": true,
"breadcrumb": false,
"typesetting": "article"
}
}
}
6 changes: 1 addition & 5 deletions website/pages/docs/_meta.en-US.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"index": "Introduction",
"install": "Installation",
"automatic": "Automatic Mode",
"manual-mode": "Manual Mode",
"internals": "Internals"
"introduction": {}
}
3 changes: 3 additions & 0 deletions website/pages/docs/_meta.es-ES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"introduction": {}
}
3 changes: 0 additions & 3 deletions website/pages/docs/_meta.zh-CN.json

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const Demo = dynamic(() =>
import('../../components/demo').then((mod) => mod.Demo),
);

# Chinese We
# Introduction

ES Test

Million.js is an extremely fast and lightweight optimizing compiler that make [components](https://react.dev) up to [_**70% faster**_](https://krausest.github.io/js-framework-benchmark/current.html).

Expand Down
8 changes: 8 additions & 0 deletions website/pages/index.en-US.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: React Hooks for Data Fetching
searchable: false
---

import { Home } from '../components/home';

<Home />
7 changes: 7 additions & 0 deletions website/pages/index.es-ES.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Biblioteca React Hooks para la obtención de datos
---

import { Home } from '../components/home';

<Home />
8 changes: 0 additions & 8 deletions website/pages/index.mdx

This file was deleted.

7 changes: 7 additions & 0 deletions website/pages/index.ru.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: React хуки для получения данных
---

import { Home } from '../components/home';

<Home />
5 changes: 2 additions & 3 deletions website/theme.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ const config: DocsThemeConfig = {
},
i18n: [
{ locale: 'en-US', text: 'English' },
{ locale: 'zh-CN', text: '中文' },
{ locale: 'de-DE', text: 'Deutsch' },
{ locale: 'ar-SA', text: 'العربية', direction: 'rtl' },
{ direction: 'rtl', locale: 'es-ES', text: 'Español RTL' },
{ locale: 'ru', text: 'Русский' }
],
useNextSeoProps() {
const { asPath } = useRouter();
Expand Down

0 comments on commit 19cc44f

Please sign in to comment.