Skip to content

Commit 6c7f2ed

Browse files
authored
feat(all)!: Multi language support (#1081)
## What does this do? Implements multi-language support based on this [design doc](https://www.notion.so/Multilingual-Support-Design-3481f8f2e65e8076ad40f613813c66dc?source=copy_link). ## How was it tested? Added tests and ran integration tests locally against this branch. ## Here's a fun image for your troubles <img width="539" height="960" alt="image" src="https://github.com/user-attachments/assets/45b7da94-912a-472d-b6e5-1fc54aaabc0e" />
1 parent 6f69ce3 commit 6c7f2ed

61 files changed

Lines changed: 1712 additions & 607 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ named-*
44
/node_modules/
55

66
/.idea
7+
/.claude
78

89
**/built/
910
**/built/**

CONTRIBUTING.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Contributing to 5e-database
2+
3+
Thanks for helping improve the 5e SRD database! This guide covers the two main ways to contribute: **data corrections** and **translations**.
4+
5+
---
6+
7+
## General workflow
8+
9+
1. Fork this repository
10+
2. Create a branch for your changes
11+
3. Open a pull request — incomplete work is welcome, we can help get it ready
12+
13+
We use [Semantic Release](https://semantic-release.gitbook.io/semantic-release/), so please follow conventional commit message conventions for your PR title:
14+
15+
| PR title prefix | Effect |
16+
| ------------------------------------- | ------------- |
17+
| `fix(...)` | Patch release |
18+
| `feat(...)` | Minor release |
19+
| `feat(...) + BREAKING CHANGE:` footer | Major release |
20+
21+
---
22+
23+
## Correcting English data
24+
25+
English source files live in `src/{year}/en/`. Edit the appropriate `5e-SRD-{Collection}.json` file and open a PR. CI will validate your changes automatically.
26+
27+
---
28+
29+
## Contributing translations
30+
31+
Translations are entirely community-driven. Adding a translation requires no database access or special tooling — only a text editor and a fork.
32+
33+
### File location
34+
35+
Create a file at:
36+
37+
```
38+
src/{year}/{lang}/5e-SRD-{Collection}.json
39+
```
40+
41+
where `{lang}` is a [BCP 47](https://www.rfc-editor.org/rfc/rfc5646) language tag (e.g. `de`, `fr`, `pt-BR`, `es-419`, `zh-Hans`).
42+
43+
**Examples:**
44+
```
45+
src/2014/de/5e-SRD-Spells.json
46+
src/2024/fr/5e-SRD-Equipment.json
47+
src/2024/pt-BR/5e-SRD-Conditions.json
48+
```
49+
50+
### File format
51+
52+
A translation file is a JSON array. Each entry must include `index` (to identify the source record) plus **only the fields you are translating**. You do not need to include every entry or every field — partial translations are fully supported.
53+
54+
```json
55+
[
56+
{
57+
"index": "acid-arrow",
58+
"name": "Säurepfeil",
59+
"desc": [
60+
"Ein glitzernder grüner Pfeil schießt auf ein Ziel..."
61+
],
62+
"higher_level": [
63+
"Wenn du diesen Zauber mit einem Zauberplatz der 3. Stufe oder höher wirkst..."
64+
]
65+
}
66+
]
67+
```
68+
69+
### Translatable fields
70+
71+
Only text fields may be translated. Structural fields (`url`, numeric values, and API references) must be omitted. `index` is required for matching but must not be translated — its value must be identical to the English source. The exact set of translatable fields depends on the collection — any text field present in the English entry for that `index` is allowed.
72+
73+
The table below shows common examples from the Spells collection:
74+
75+
| Field | Translatable |
76+
| --------------------- | ----------------------------------------------------------- |
77+
| `name` | Yes |
78+
| `desc` | Yes |
79+
| `higher_level` | Yes |
80+
| `index` | No — include it for matching, but don't translate its value |
81+
| `url` | No |
82+
| Numeric values | No |
83+
| API reference objects | No |
84+
85+
Other collections expose different text fields (e.g. `summary` on subclasses, `description` on some entries). Include any text field that appears in the English source — CI will reject fields that don't exist there.
86+
87+
### Validation rules
88+
89+
The test suite (`npm test`, also run by CI on every PR) will fail if your translation file:
90+
91+
- Contains an `index` that does not exist in the corresponding English file
92+
- Contains a field that does not exist in the English entry for that `index`
93+
- Contains duplicate `index` values
94+
- Produces an invalid document when translation fields are merged with the English entry (Zod schema validation)
95+
96+
Run `npm test` locally before opening a PR to catch these issues early.
97+
98+
### Partial translations are fine
99+
100+
You do not need to translate every entry or every field. The API will fall back to English on a per-field basis for anything not covered by a translation. A file covering even a handful of entries is a useful contribution.
101+
102+
---
103+
104+
## Code of Conduct
105+
106+
See the [Code of Conduct](https://github.com/5e-bits/5e-database/wiki/Code-of-Conduct).

0 commit comments

Comments
 (0)