Skip to content

Commit d61cbbf

Browse files
brunoborgesCopilot
andcommitted
docs: update copilot-instructions.md with i18n and enterprise category
- Add enterprise to categories list and display names table - Document translations/ directory structure and locales.properties - Add full Internationalization (i18n) section referencing specs/i18n/i18n-spec.md - Document UI strings, content translation schema, and fallback behavior - Update generated files section with locale-specific output paths - Expand manually maintained files and project structure Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d5e6bf5 commit d61cbbf

File tree

1 file changed

+75
-11
lines changed

1 file changed

+75
-11
lines changed

.github/copilot-instructions.md

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,48 @@ content/streams/stream-tolist.json
1818
...
1919
```
2020

21-
**Categories:** `language`, `collections`, `strings`, `streams`, `concurrency`, `io`, `errors`, `datetime`, `security`, `tooling`
21+
**Categories:** `language`, `collections`, `strings`, `streams`, `concurrency`, `io`, `errors`, `datetime`, `security`, `tooling`, `enterprise`
2222

2323
### Generated Files (DO NOT EDIT)
2424

2525
The following are **generated by `html-generators/generate.java`** and must not be edited directly:
2626

27-
- `site/index.html` — homepage with preview cards (generated from `templates/index.html`)
28-
- `site/language/*.html`, `site/collections/*.html`, etc. — detail pages
29-
- `site/data/snippets.json` — aggregated search index
27+
- `site/index.html` — English homepage with preview cards (generated from `templates/index.html`)
28+
- `site/language/*.html`, `site/collections/*.html`, etc. — English detail pages
29+
- `site/data/snippets.json` — English aggregated search index
30+
- `site/{locale}/index.html` — localized homepage (e.g., `site/es/index.html`)
31+
- `site/{locale}/language/*.html`, etc. — localized detail pages
32+
- `site/{locale}/data/snippets.json` — localized search index
3033

31-
Run `jbang html-generators/generate.java` to rebuild all generated files from the JSON sources.
34+
Run `jbang html-generators/generate.java` to rebuild all generated files from the JSON sources and translations.
3235

3336
### Manually Maintained Files
3437

35-
- `site/app.js` — client-side search, filtering, code highlighting
38+
- `site/app.js` — client-side search, filtering, code highlighting, locale detection
3639
- `site/styles.css` — all styling
37-
- `templates/slug-template.html` — HTML template with `{{placeholder}}` tokens used by the generator
38-
- `templates/index.html` — homepage template with `{{tipCards}}` and `{{snippetCount}}` placeholders
40+
- `templates/slug-template.html` — HTML template with `{{placeholder}}` tokens (content + UI strings) used by the generator
41+
- `templates/index.html` — homepage template with `{{tipCards}}`, `{{snippetCount}}`, and UI string placeholders
3942
- `templates/index-card.html` — preview card template for the homepage grid
43+
- `html-generators/categories.properties` — category ID → display name mapping
44+
- `html-generators/locales.properties` — supported locales registry (locale=Display name)
45+
- `translations/strings/{locale}.yaml` — UI strings per locale (labels, nav, footer, etc.)
46+
- `translations/content/{locale}/` — translated pattern JSON files (partial, translatable fields only)
4047

4148
### Project Structure
4249

4350
```
44-
content/ # Source JSON files (one per pattern, organized by category)
51+
content/ # English content JSON files (source of truth, one per pattern)
52+
translations/ # All i18n artifacts
53+
strings/ # UI strings per locale (en.yaml, es.yaml, pt-BR.yaml)
54+
content/ # Translated pattern files per locale (partial, translatable fields only)
55+
es/ # Spanish translations (mirrors content/ folder structure)
56+
pt-BR/ # Brazilian Portuguese translations
4557
site/ # Deployable site (static assets + generated HTML)
46-
templates/ # HTML templates for detail pages
47-
html-generators/ # Build scripts and pre-built JAR
58+
es/ # Generated Spanish pages
59+
pt-BR/ # Generated Portuguese pages
60+
templates/ # HTML templates with {{…}} tokens for content + UI strings
61+
html-generators/ # Build scripts, categories.properties, locales.properties
62+
specs/ # Feature specifications (e.g., i18n-spec.md)
4863
```
4964

5065
## JSON Snippet Schema
@@ -101,6 +116,8 @@ Each `content/category/slug.json` file has this structure:
101116

102117
## Category Display Names
103118

119+
Categories and their display names are defined in `html-generators/categories.properties`:
120+
104121
| ID | Display |
105122
|----|---------|
106123
| `language` | Language |
@@ -113,12 +130,59 @@ Each `content/category/slug.json` file has this structure:
113130
| `datetime` | Date/Time |
114131
| `security` | Security |
115132
| `tooling` | Tooling |
133+
| `enterprise` | Enterprise |
116134

117135
## Adding a New Pattern
118136

119137
1. Create `content/category/new-slug.json` with all required fields
120138
2. Update `prev`/`next` in the adjacent patterns' JSON files
121139
3. Run `jbang html-generators/generate.java`
140+
4. (Optional) Create translated content files under `translations/content/{locale}/category/new-slug.json` with only translatable fields — or let the AI translation workflow handle it
141+
142+
## Internationalization (i18n)
143+
144+
The site supports multiple languages. See `specs/i18n/i18n-spec.md` for the full specification.
145+
146+
### Key Concepts
147+
148+
- **UI strings:** Hard-coded template text (labels, nav, footer) is extracted into `translations/strings/{locale}.yaml`. Templates use `{{dotted.key}}` tokens (e.g., `{{nav.allPatterns}}`, `{{sections.codeComparison}}`). Missing keys fall back to the English value with a build-time warning.
149+
- **Content translations:** Translated pattern files under `translations/content/{locale}/` contain **only** translatable fields (`title`, `summary`, `explanation`, `oldApproach`, `modernApproach`, `whyModernWins`, `support.description`). All other fields (`oldCode`, `modernCode`, `slug`, `id`, `prev`, `next`, `related`, `docs`, etc.) are always taken from the English source.
150+
- **Locale registry:** `html-generators/locales.properties` lists supported locales (format: `locale=Display name`). The first entry is the default.
151+
- **English is a first-class locale:** All locales — including English — go through the same build pipeline.
152+
- **Fallback:** If a pattern has no translation file for a locale, the English content is used and an "untranslated" banner is shown.
153+
154+
### Supported Locales
155+
156+
Defined in `html-generators/locales.properties`:
157+
158+
| Locale | Display Name |
159+
|--------|-------------|
160+
| `en` | English |
161+
| `es` | Español |
162+
| `pt-BR` | Português (Brasil) |
163+
164+
### Content Translation File Example
165+
166+
Translation files contain **only** translatable fields — no structural data:
167+
168+
```json
169+
// translations/content/pt-BR/language/type-inference-with-var.json
170+
{
171+
"title": "Inferência de tipo com var",
172+
"oldApproach": "Tipos explícitos",
173+
"modernApproach": "Palavra-chave var",
174+
"summary": "Use var para deixar o compilador inferir o tipo local.",
175+
"explanation": "...",
176+
"whyModernWins": [
177+
{ "icon": "", "title": "Menos ruído", "desc": "..." },
178+
{ "icon": "👁", "title": "Mais legível", "desc": "..." },
179+
{ "icon": "🔒", "title": "Seguro", "desc": "..." }
180+
],
181+
"support": {
182+
"description": "Amplamente disponível desde o JDK 10 (março de 2018)"
183+
}
184+
}
185+
```
122186

123187
## Local Development
124188

0 commit comments

Comments
 (0)