Bilingual (English/Chinese) corporate website built with Astro 5.0 + Tailwind CSS.
Upstream Labs is a unique combination of venture capital, Y Combinator methodology, and incubator resources, dedicated to empowering the next generation of startups.
This website is based on the AstroWind template with bilingual (English/Chinese) support implemented using Astro's built-in i18n routing and i18next for translations.
- Framework: Astro 5.0
- Styling: Tailwind CSS
- i18n Routing: Astro built-in i18n
- Translations: i18next
- TypeScript: Type-safe development
- Icons: Astro Icon (Tabler icons)
# Install dependencies
npm install
# Start development server
npm run devThe site will be available at http://localhost:4321
- English:
http://localhost:4321/ - Chinese:
http://localhost:4321/cn/
Important: URLs use trailing slashes (e.g., /cn/ not /cn)
# Build for production
npm run build
# Preview production build
npm run preview- English (default):
/- No language prefix - Chinese:
/cn/- Language prefix
Examples:
- Homepage:
/(English),/cn/(Chinese) - About:
/about/(English),/cn/about/(Chinese) - Contact:
/contact/(English),/cn/contact/(Chinese)
Note: All URLs use trailing slashes due to trailingSlash: true configuration.
- Routing: Astro's built-in i18n routing (configured in
astro.config.ts) - Language Detection: Automatic detection from URL path
- Translations: JSON files in
src/i18n/locales/{en,zh}/ - SEO: Automatic hreflang tags for search engines
- Language Switcher: Header component for easy switching
/
├── src/
│ ├── i18n/ # Translation infrastructure
│ │ ├── locales/ # Translation JSON files
│ │ │ ├── en/ # English translations
│ │ │ │ ├── common.json
│ │ │ │ ├── nav.json
│ │ │ │ ├── home.json
│ │ │ │ └── footer.json
│ │ │ └── zh/ # Chinese translations
│ │ │ ├── common.json
│ │ │ ├── nav.json
│ │ │ ├── home.json
│ │ │ └── footer.json
│ │ ├── utils.ts # i18n utilities
│ │ └── index.ts # Exports
│ │
│ ├── pages/ # English pages (root)
│ │ ├── index.astro
│ │ ├── about.astro
│ │ ├── contact.astro
│ │ └── zh/ # Chinese pages
│ │ ├── index.astro
│ │ ├── about.astro
│ │ └── contact.astro
│ │
│ ├── components/
│ │ ├── common/
│ │ │ └── LanguageSwitcher.astro
│ │ └── widgets/
│ │
│ ├── layouts/
│ │ └── Layout.astro # Base layout with language detection
│ │
│ └── config.yaml # Site configuration
│
├── astro.config.ts # Astro + i18n configuration
├── package.json
└── README.md
Edit JSON files in src/i18n/locales/{en,zh}/:
English (src/i18n/locales/en/common.json):
{
"action": {
"submit": "Submit"
}
}Chinese (src/i18n/locales/zh/common.json):
{
"action": {
"submit": "提交"
}
}---
import { useTranslations } from '~/i18n';
const { t } = await useTranslations('en'); // or 'zh'
---
<button>{t('action.submit', { ns: 'common' })}</button>The current language is automatically detected from the URL:
---
import { getLangFromUrl } from '~/i18n';
const currentLang = getLangFromUrl(Astro.url);
const { t } = await useTranslations(currentLang);
---To add a new bilingual page:
-
Create English version in
src/pages/touch src/pages/services.astro
-
Create Chinese version in
src/pages/zh/touch src/pages/zh/services.astro
-
Use translations in both files
--- import { useTranslations } from '~/i18n'; const { t } = await useTranslations('en'); // or 'zh' ---
-
Add navigation (if needed) - update navigation configuration
Translation files are organized by namespace:
- common.json: Site-wide content (site name, CTAs, etc.)
- nav.json: Navigation labels
- footer.json: Footer content
- home.json: Homepage-specific content
- [page].json: Page-specific content (can be added as needed)
- Hreflang tags: Automatic alternate language links
- Language-specific meta: Title, description per language
- Sitemap: Includes all language versions
- OpenGraph: Correct locale for social sharing
- ✅ Bilingual infrastructure
- ✅ Route-based language switching
- ✅ Translation system
- ✅ Language switcher UI
- ✅ SEO optimization (hreflang)
- ✅ Basic pages (home, about, contact)
- Content translation (real Upstream Labs content)
- Custom branding (colors, fonts, logo)
- Additional pages
- Blog translations
- Advanced features (contact forms, newsletter)
- Performance optimization
# Run all checks
npm run check
# Type checking
npm run check:astro
# Linting
npm run check:eslint
# Format checking
npm run check:prettier
# Auto-fix issues
npm run fixEdit src/config.yaml to update:
- Site name and URL
- Metadata (title, description)
- Social media handles
- Analytics
- Blog settings
The bilingual setup is configured in astro.config.ts:
i18n: {
defaultLocale: 'en',
locales: ['en', 'cn'],
routing: {
prefixDefaultLocale: false, // English at root: /
redirectToDefaultLocale: false, // Disable auto-redirect
}
}Important Settings:
prefixDefaultLocale: false- English uses root URLs without/en/prefixredirectToDefaultLocale: false- Prevents automatic redirects based on browser language- Edit to add new languages, change default language, or modify routing behavior
The site is built as a static site and can be deployed to:
- Netlify: Pre-configured (
netlify.toml) - Vercel: Pre-configured (
vercel.json) - Docker: Dockerfile included
- Any static hosting service
npm run buildGenerates static files in dist/ directory.
See LICENSE.md file for details.
For issues or questions, please contact the Upstream Labs team.