Skip to content

feat: Enables translations #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
## Elysia documentation

Written by VitePress

### How to add translations

#### Adding a net-new language

To add a net-new language:

1. Add the locale to the exported object in `/intl/locales.ts`. Use other languages as examples for what you need to add.
2. The new language object should have a `label` (the native name of the language), `lang` (the ISO language code), and a `themeConfig` where you pass the language code to the `generateThemeConfig` helper function.

By default this new language will have all English content as a fallback. Follow the steps below to translate docs or the navigation.

#### To the navigation/sidebar

1. In `/menus` find the `text` string you want to translate in either `nav.ts` or `sidebar.ts`
2. Copy that string exactly as it appears in that object.
3. In `/intl/strings.ts` CMD+F for the string you want to translate. If it does not exist create a new object.
4. Add the lang code to the object with your translation.
5. Run the site locally to confirm your changes in the new language as well as checking nothing changed in the 'en' version.

#### Translating docs

All the files and directories in `/docs` represent the `en` content, with the exception of any directory named after a locale (for example `/fr` for French). Any directory named after a locale contains docs specifically translated for that locale. If a doc doesn't exist for a specific locale, redirects are set up to serve fallback content.

Given the above, if a doc doesn't exist in the locale's directory:

1. Copy the doc
2. Create a file with the same name in the locale's directory
3. Paste the copied content and translate.
303 changes: 2 additions & 301 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from 'vitepress'
import locales from '../../intl/locales'

const description =
'Ergonomic Framework for Humans. TypeScript framework supercharged by Bun with End - to - End Type Safety, unified type system and outstanding developer experience'
Expand All @@ -9,6 +10,7 @@ export default defineConfig({
// description,
ignoreDeadLinks: true,
lastUpdated: true,
locales: locales,
markdown: {
theme: {
light: 'github-light',
Expand Down Expand Up @@ -101,307 +103,6 @@ export default defineConfig({
provider: 'local'
},
logo: '/assets/elysia.svg',
nav: [
{
text: 'Quick Start',
link: '/quick-start'
},
{
text: 'Plugins',
link: '/plugins/overview'
},
{
text: 'Blog',
link: '/blog'
}
],
sidebar: [
{
text: '👋 Getting Started',
items: [
{
text: 'Introduction',
link: '/introduction'
},
{
text: 'Quick Start',
link: '/quick-start'
},
{
text: 'At Glance',
link: '/at-glance'
},
{
text: 'Table of Content',
link: '/table-of-content'
}
]
},
{
text: '✨ Essential',
collapsed: true,
items: [
{
text: 'Route',
link: '/essential/route'
},
{
text: 'Path',
link: '/essential/path'
},
{
text: 'Handler',
link: '/essential/handler'
},
{
text: 'Context',
link: '/essential/context'
},
{
text: 'Plugin',
link: '/essential/plugin'
},
{
text: 'Life Cycle',
link: '/essential/life-cycle'
},
{
text: 'Schema',
link: '/essential/schema'
},
{
text: 'Scope',
link: '/essential/scope'
}
]
},
{
text: '🔎 Validation',
collapsed: true,
items: [
{
text: 'Overview',
link: '/validation/overview'
},
{
text: 'Schema Type',
link: '/validation/schema-type'
},
{
text: 'Primitive Type',
link: '/validation/primitive-type'
},
{
text: 'Elysia Type',
link: '/validation/elysia-type'
},
{
text: 'Error Provider',
link: '/validation/error-provider'
},
{
text: 'Reference Model',
link: '/validation/reference-model'
}
]
},
{
text: '⏳ Life Cycle',
collapsed: true,
items: [
{
text: 'Overview',
link: '/life-cycle/overview'
},
{
text: 'On Request',
link: '/life-cycle/request'
},
{
text: 'Parse',
link: '/life-cycle/parse'
},
{
text: 'Transform',
link: '/life-cycle/transform'
},
{
text: 'Before Handle',
link: '/life-cycle/before-handle'
},
{
text: 'After Handle',
link: '/life-cycle/after-handle'
},
{
text: 'Map Response',
link: '/life-cycle/map-response'
},
{
text: 'On Error',
link: '/life-cycle/on-error'
},
{
text: 'On Response',
link: '/life-cycle/on-response'
},
{
text: 'Trace',
link: '/life-cycle/trace'
}
]
},
{
text: '🧭 Patterns',
collapsed: true,
items: [
{
text: 'Group',
link: '/patterns/group'
},
{
text: 'Cookie',
link: '/patterns/cookie'
},
{
text: 'Cookie Signature',
link: '/patterns/cookie-signature'
},
{
text: 'Web Socket',
link: '/patterns/websocket'
},
{
text: 'Documentation',
link: '/patterns/documentation'
},
{
text: 'Unit Test',
link: '/patterns/unit-test'
},
{
text: 'Mount',
link: '/patterns/mount'
},
{
text: 'Lazy Loading Module',
link: '/patterns/lazy-loading-module'
},
{
text: 'Macro',
link: '/patterns/macro'
}
]
},
{
text: '🪴 Eden',
collapsed: true,
items: [
{
text: 'Overview',
link: '/eden/overview.md'
},
{
text: 'Installation',
link: '/eden/installation.md'
},
{
text: 'Eden Treaty',
link: '/eden/treaty.md'
},
{
text: 'Eden Fetch',
link: '/eden/fetch.md'
},
{
text: 'Test',
link: '/eden/test.md'
}
]
},
{
text: '🔌 Plugins',
items: [
{
text: 'Official Plugins',
link: '/plugins/overview',
collapsed: true,
items: [
{
text: 'Bearer',
link: '/plugins/bearer'
},
{
text: 'CORS',
link: '/plugins/cors'
},
{
text: 'Cron',
link: '/plugins/cron'
},
{
text: 'GraphQL Apollo',
link: '/plugins/graphql-apollo'
},
{
text: 'GraphQL Yoga',
link: '/plugins/graphql-yoga'
},
{
text: 'HTML',
link: '/plugins/html'
},
{
text: 'JWT',
link: '/plugins/jwt'
},
{
text: 'Server Timing',
link: '/plugins/server-timing'
},
{
text: 'Static',
link: '/plugins/static'
},
{
text: 'Stream',
link: '/plugins/stream'
},
{
text: 'Swagger',
link: '/plugins/swagger'
},
{
text: 'trpc',
link: '/plugins/trpc'
}
]
}
]
},
{
text: 'Integration',
collapsed: true,
items: [
{
text: 'Docker',
link: '/integrations/docker'
},
{
text: 'Nextjs',
link: '/integrations/nextjs'
},
{
text: 'Astro',
link: '/integrations/astro'
}
// {
// text: 'Cheat Sheet',
// link: '/integrations/cheat-sheet'
// }
]
}
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/elysiajs/elysia' },
{ icon: 'twitter', link: 'https://twitter.com/elysiajs' },
Expand Down
Loading