Every Electron API has parts of its documentation that should remain in English. Let's look at an example:
#### `win.setAspectRatio(aspectRatio[, extraSize])` _macOS_
* `aspectRatio` Float - The aspect ratio to maintain for some portion of the
content view.
* `extraSize` [Size](structures/size.md) - The extra size not to be included while
maintaining the aspect ratio.
This will make a window maintain an aspect ratio. The extra size allows a
developer to have space, specified in pixels, not included within the aspect
ratio calculations. This API already takes into account the difference between a
window's size and its content size.
In the above example, the following things should remain untouched:
- heading level:
####
- method name and signature:
win.setAspectRatio(aspectRatio[, extraSize])
- operating System:
macOS
- argument list bullets:
*
- argument names:
aspectRatio
and extraSize
- argument types:
Float
and Size
The only things that should be translated here are the descriptions, both for the arguments as well as the method itself:
The aspect ratio to maintain for some portion of the content view.
The extra size not to be included while maintaining the aspect ratio.
This will make a window maintain an aspect ratio. ...
The Current Approach
In an effort to reduce the likelihood of translators changing content that should not be changed, I extracted all descriptions into a YML file. Here's an excerpt:
app.methods.hide.description: Hides all application windows without minimizing them.
app.methods.show.description: >-
Shows application windows after they were hidden. Does not automatically focus
them.
app.methods.getAppPath.returns.description: The current application directory.
app.methods.getPath.description: 'You can request the following paths by the name:'
app.methods.getPath.returns.description: >-
A path to a special directory or file associated with name. On failure an
Error is thrown.
This seemed like a good approach for a few reasons:
- no way for translators to edit content that shouldn't be edited
- descriptions are structured and can therefore be used to create a localized structured API docs data. This could then be used to make localized typescript annotations, snazzier localized API docs on the website, etc.
The Problem with the Existing Approach
The YAMLized descriptions has proven to be a bit confusing for translators so far. It seems that in some cases it's difficult to know how to translate a description without the surrounding context.
Here's an example of a contributor being confused #58
An Alternative Approach
I'm thinking maybe we should scrap this api-descriptions.yml
idea in favor of pulling in all the raw markdown files from electron/electron/tree/master/docs/api.
This might be a better approach for a few reasons:
- Translators would always have the full context when translating API docs.
- Translators would have the opportunity to learn more about Electron's API in general as they go.
- The resulting content in the electron-i18n repo would stand on its own as a useable form of translated documentation.
git clone https://github.com/electron/electron-i18n
for an offline copy of Electron's documentation in every language.
To avoid the problem of translators changing content that should not be changed, we could enforce this at the GitHub pull-request level by running electron-docs-linter and electron-typescript-definitions as part of the existing test suite that runs on Travis.
Thoughts?
Curious to hear if people have feedback on this idea. It's not a lot of work to make this change on my end, but I first want to make sure that this is actually closer to what folks want and expect when translating Electron's API docs.