62 lines
3.6 KiB
Markdown
62 lines
3.6 KiB
Markdown
## Purpose
|
|
|
|
Defines the content localisation system for the Qumo website, including the JSON content files structure and the `i18n.ts` helper that provides locale-appropriate content to pages and components.
|
|
|
|
## Requirements
|
|
|
|
### Requirement: Locale content JSON files contain global meta fields
|
|
`src/content/en.json` and `src/content/nl.json` SHALL each contain a top-level `"meta"` key with the following fields:
|
|
- `siteName: string` — the site name (e.g., `"Qumo"`)
|
|
- `defaultTitle: string` — default page title (used as fallback)
|
|
- `defaultDescription: string` — default meta description (used as fallback)
|
|
- `defaultOgImage: string` — default OG image path; may be empty string initially
|
|
|
|
#### Scenario: en.json has correct meta structure
|
|
- **WHEN** `src/content/en.json` is parsed as JSON
|
|
- **THEN** it SHALL have a `meta` object with string values for `siteName`, `defaultTitle`, `defaultDescription`, and `defaultOgImage`
|
|
|
|
#### Scenario: nl.json has correct meta structure
|
|
- **WHEN** `src/content/nl.json` is parsed as JSON
|
|
- **THEN** it SHALL have the same `meta` object shape as `en.json`, with Dutch-language values for `defaultTitle` and `defaultDescription`
|
|
|
|
### Requirement: i18n helper returns correct content for locale
|
|
`src/content/i18n.ts` SHALL export a function `getContent(locale: string)` that returns the parsed content object for the given locale. It SHALL return the EN content object for any unrecognized locale string.
|
|
|
|
#### Scenario: Returns EN content for "en" locale
|
|
- **WHEN** `getContent("en")` is called
|
|
- **THEN** the function SHALL return the parsed contents of `src/content/en.json`
|
|
|
|
#### Scenario: Returns NL content for "nl" locale
|
|
- **WHEN** `getContent("nl")` is called
|
|
- **THEN** the function SHALL return the parsed contents of `src/content/nl.json`
|
|
|
|
#### Scenario: Falls back to EN for unknown locale
|
|
- **WHEN** `getContent("fr")` or any unrecognized locale string is called
|
|
- **THEN** the function SHALL return the parsed contents of `src/content/en.json`
|
|
|
|
### Requirement: Locale content JSON files contain nav strings
|
|
`src/content/en.json` and `src/content/nl.json` SHALL each contain a top-level `"nav"` key with the following structure:
|
|
- `links`: array of objects with `label: string` and `href: string` for each nav link
|
|
- `cta`: string — label for the Connect CTA button
|
|
- `ctaHref`: string — href for the Connect CTA button
|
|
- `langSwitch`: object with `en: string` and `nl: string` labels for the language switcher
|
|
|
|
#### Scenario: en.json nav section has correct structure
|
|
- **WHEN** `src/content/en.json` is parsed as JSON
|
|
- **THEN** it SHALL have a `nav` object containing `links` (array of 3 items with `label` and `href`), `cta` string, `ctaHref` string, and `langSwitch` object with `en` and `nl` keys
|
|
|
|
#### Scenario: nl.json nav section has Dutch labels
|
|
- **WHEN** `src/content/nl.json` is parsed as JSON
|
|
- **THEN** `nav.links` SHALL contain Dutch labels ("Diensten", "AI Launchpad", "Over Ons"), `nav.cta` SHALL be "Verbind", and `nav.ctaHref` SHALL be "/nl/contact"
|
|
|
|
#### Scenario: Build succeeds with nav strings added
|
|
- **WHEN** `npm run build` is executed after adding `nav` keys to both JSON files
|
|
- **THEN** the build SHALL complete without TypeScript errors
|
|
|
|
### Requirement: Content files use static imports (no runtime fetch)
|
|
The `i18n.ts` helper SHALL use static ES module imports (`import enContent from './en.json'`) rather than dynamic `fetch` or `fs.readFile`. This ensures type safety and tree-shaking at build time.
|
|
|
|
#### Scenario: Build succeeds with static imports
|
|
- **WHEN** `npm run build` is executed in the `website/` directory
|
|
- **THEN** the build SHALL complete without errors, with locale content bundled statically
|