Add i18n support for homepage (国际化官网首页)#31
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds internationalization (i18n) support to the ObjectStack homepage, enabling both English and Chinese language versions. The implementation leverages the existing Next.js i18n routing infrastructure while keeping translations maintainable through a centralized module.
Changes:
- Created a new i18n module with TypeScript-typed translations for English and Chinese
- Converted the homepage component to async to access route parameters for language detection
- Replaced all hardcoded English strings with dynamic translation variables
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/docs/lib/homepage-i18n.ts | New translation module defining the HomepageTranslations interface and providing English/Chinese translation objects with a language selector function |
| apps/docs/app/[lang]/page.tsx | Updated homepage to extract language from route params and use translations instead of hardcoded strings |
| packages/spec/src/system/manifest.test.ts | Removed unused MenuItem test cases and import |
| packages/spec/src/data/field.test.ts | Fixed extraneous closing brace |
| expect(() => MenuItemSchema.parse({ path: '/test' })).toThrow(); | ||
| }); | ||
| }); | ||
| import { ManifestSchema, type ObjectStackManifest } from './manifest.zod'; |
There was a problem hiding this comment.
The removed MenuItemSchema tests provided validation coverage for the menu item structure. Ensure that menu item validation is adequately covered elsewhere in the test suite, or consider keeping these tests to maintain comprehensive schema validation.
The homepage was hardcoded in English. This adds Chinese translations while leveraging the existing middleware and routing infrastructure.
Changes
Created
apps/docs/lib/homepage-i18n.tsHomepageTranslationsdefining all translatable stringsgetHomepageTranslations(lang)selector with fallback to EnglishUpdated
apps/docs/app/[lang]/page.tsxlangfrom route paramsExample
Screenshots
English (/):

Chinese (/cn):

Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.