Description
Last year, we introduced the ability to translate and localize OpenAPI specs generated within the MediaWiki framework. Today, the spec language follows the default language for the wiki it is being requested on. However, we would also like to offer the ability to request the spec in any language. The ability to request any language will support "Project Frodo", where specs are being pulled and displayed outside of the context of MediaWiki. Additionally, there are some users who may prefer using a spec in cases where their preferred language does not match the default wiki value.
Conditions of Acceptance
- Allow a language to be specified when requesting a generated spec using the /specs endpoint
- Language is specified using 2-character ISO code (with a few exceptions)
- Some languages may also have dialect options specified beyond the ISO version -- for example, zh-hans vs zh-hant.
- When a language is specified, the spec is generated in the requested language (if translation is available). If no language is specified, continue using the default language for the requested wiki. This includes cases where an invalid language code is provided; instead of throwing an error, simply fallback to the default language.
Implementation details
Two options exist for allowing a language to be specified: 1) Using the standard Accept-Lanaguage header, 2) A query parameter, or 3) Adding a path parameter.
For now, the product recommendation is to add a query parameter for this specification. This is because query parameters are more explicit and clear on the request, more cacheable, and easier for most users to deal with than headers. However, if a strong case is made for one of the other approaches, we can discuss it as a team.
The query parameter pattern would look something like:
https://test.wikipedia.org/w/rest.php/specs/v0/module/attribution/v0-beta?lang=es
A few ideas for the query parameter name itself:
- [RECOMMENDED] ?lang=en --> Seems to be fairly commonly used across REST implementations
- ?uselang=en --> Consistent with the Action API
- ?language=en --> Potential clarity over an abbreviated version; out in the wild, this frequently has both words spelled out (eg: ?language=English)