-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Iterating on Crowdin scripts, Link, pages, etc
- Loading branch information
Brian Vaughn
committed
May 11, 2018
1 parent
70b9bd5
commit 31381a8
Showing
12 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.idea | ||
node_modules | ||
public | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
__translations/ | ||
__exports/ | ||
translations/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
## How does this work? | ||
|
||
### Downloading content from Crowdin | ||
|
||
This subdirectory contains some JavaScript files as well as a symlink for the default language (English) that points to [the `content` directory](https://github.com/reactjs/reactjs.org/tree/master/content): | ||
```sh | ||
. | ||
└── crowdin | ||
├── config.js # Crowdin configuration settings | ||
├── download.js # Node Download script | ||
└── translations | ||
└── en-US -> ../../content | ||
``` | ||
|
||
Translations can be downloaded locally with `yarn crowdin:download`. This uses the Crowdin API to download data into an `__exports` subdirectory: | ||
```sh | ||
. | ||
└── crowdin | ||
├── config.js # Crowdin configuration settings | ||
├── download.js # Node Download script | ||
├── translations | ||
│ └── en-US -> ../../content | ||
└── __exports | ||
└── ... # Downloaded translations go here | ||
``` | ||
|
||
Next the task identifies which languages have been translated past a certain threshold (specified by `crowdin/config.js`). For these languages, the script creates symlinks in the `translations` subdirectory: | ||
```sh | ||
. | ||
└── crowdin | ||
├── config.js # Crowdin configuration settings | ||
├── download.js # Node Download script | ||
├── translations | ||
│ ├── en-US -> ../../content | ||
│ ├── es-ES -> ../__exports/.../es-ES | ||
│ ├── zh-CN -> ../__exports/.../zh-CN | ||
│ └── ... # Other symlinks go here | ||
└── __exports | ||
└── ... # Downloaded translations go here | ||
``` | ||
|
||
### Gatsby integration | ||
|
||
A new (local) `gatsby-plugin-crowdin` plugin has been created that knows how to create localized links to certain sections of the website. **For now, only content from [the `content/docs` directory](https://github.com/reactjs/reactjs.org/tree/master/content/docs) is localized. All other sections/pages remain English only.** | ||
|
||
The `gatsby-source-filesystem` plugin has also been reconfigured to read all content from the `crowdin/translations/*` (symlinked) directories rather than `content`. This way it consumes translated content when available. (Crowdin provides default language content for sections that have not yet been translated for any given locale.) | ||
|
||
Because of the default symlink (`crowdin/translations/en-US` -> `content`) Gatsby will serve English content when run locally, even if the Crowdin script has not been run. This should enable fast iteration and creation of new content. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
const path = require('path'); | ||
|
||
// Also relates to the crowdin.yaml file in the root directory | ||
module.exports = { | ||
key: process.env.CROWDIN_API_KEY, | ||
url: 'https://api.crowdin.com/api/project/react', | ||
threshold: 50, | ||
downloadedRootDirectory: 'test-17', | ||
downloadedRootDirectory: path.join('test-17', 'docs'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters