43 lines
2.4 KiB
Markdown
43 lines
2.4 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: 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
|