Currently there is no way to specify language variant via the REST API, and without knowing a specific language variant, Parsoid cannot produce exact same content as Wikipedia page
e.g.
https://zh.wikipedia.org/api/rest_v1/page/html/%E4%B8%AD%E5%9C%8B
it contains raw wikitext markup "-{ }-"
```
-{H|zh:繁体字;zh-cn:繁体字;zh-tw:正體字;zh-hk:繁體字;zh-mo:繁體字;zh-sg:繁体字;}-
```
what we want is: allow client to specify language variant explicitly, and Parsoid return the exact same content as it is on Wikipedia, e.g.
https://zh.wikipedia.org/api/rest_v1/page/html/%E4%B8%AD%E5%9C%8B?lang=zh-cn
will return content same as:
https://zh.wikipedia.org/zh-cn/%E4%B8%AD%E5%9C%8B
## Requirements
- Continue to expose the original content, without variant conversions applied (as is the case right now).
- Additionally, offer content with variant conversions applied for read-only use cases.
## Candidate solutions
### Domains
The REST API is very much built around domains as the primary means of selecting project, storage & general configuration. As such, it would be fairly straightforward to assign separate domains to variants. Examples:
- `zh.wikipedia.org/api/rest_v1/..`: Un-translated content. Used for editing.
- `zh-cn.wikipedia.org/api/rest_v1/..`: Simplified Chinese. Read-only.
- `zh-tw.wikipedia.org/api/rest_v1/..`: Traditional Chinese. Read-only.
#### Considerations
- Wildcard certs are tied to a single sub-domain level, so introducing a second level for variants (ex: `cn.zh.wikipedia.org`) would not be easy.
#### Advantages
- Simple to implement in REST API, does not require Varnish changes
#### Disadvantages
- Requires new domains.
- Does not support listings of variants.
### Path prefixes
Instead of using domains, use special path prefixes to select variants. The REST API currently uses `/api/rest_v1/`, which makes fitting variants into this scheme a bit awkward. T114662 proposes a scheme like `/wiki-cn/`, which could be adapted to `/api-cn/`.
The Chinese Wikipedia currently replaces `/wiki/` with the variant, as in `zh.wikipedia.org/zh-cn/Sometitle`. Fitting the API into this scheme without conflicts is tricky. The best I can think of is `zh.wikipedia.org/api/zh-cn/Sometitle`.
#### Advantages
- Closer to current usage on Chinese Wikipedia.
#### Disadvantages
- Does not really support listings of variants either.
- Overloads root path namespace, opening the door to conflicts or less-than-obvious variant path names.
## See also
- {T114662}
- {T114640}