Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
feat: docs i18n support (continuation from #14818) (#17190)
Browse files Browse the repository at this point in the history
* Initial commit for i18n support

* Bring out index page

* Lint
	modified:   src/pages/index.js

* More Crowdin ephemera

* copy src content to i18n/**/docusaurus-plugin-content-docs/current folders

* run write-translations

* remove superflous files in i18n

* fix formatting

* remove icons folders from translations, add ja, pt, vi translations

* fix formatting

* update translation JSON files

* add crowdin support & crowdin:sync command, sync with crowdin

* exclude failing locales

* remove i18n from git cache, add write-heading-ids script

* add crowdin:sync to before_install.sh script

* add write-i18m shortening script & crowdin:download script (also to before_install.sh)

* move crowdin:download from before_install.sh to prebuild hook

* remove prebuild hook

* remove crowdin script, bump deps

* re-add cli/usage

* update package-lock.json

* add translation sync to build.sh for master

* update README

* add ja to localesNotBuilding, write e-ids

* fix formatting

* get on sync with master

* replace check for master branch

* change build script to work on travis

* use refs instead of names

* fix build.sh

* replace head ref check with channel check

* get stable channel in build.sh

* remove zip

* remove header ids

Co-authored-by: rmshea <[email protected]>
  • Loading branch information
timhagn and rmshea authored May 28, 2021
1 parent e833d2b commit 53c91ee
Show file tree
Hide file tree
Showing 171 changed files with 24,772 additions and 35,649 deletions.
4 changes: 4 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vercel.json

# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand All @@ -28,3 +29,6 @@ yarn-error.log*
/src/tests.ok
/src/cli/usage.md
/src/.gitbook/assets/*.svg

# i18n gets generated by write-translations & Crowdin
i18n
24 changes: 21 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Static content delivery is handled using `vercel`.

### Installing Docusaurus

```
```sh
$ npm install
```

Expand All @@ -15,7 +15,7 @@ This command starts a local development server and open up a browser window.
Most changes are reflected live without having to restart the server.
(You might have to run build.sh first if you run into failures)

```
```sh
$ npm run start
```

Expand All @@ -24,10 +24,28 @@ $ npm run start
This command generates static content into the `build` directory and can be
served using any static contents hosting service.

```
```sh
$ docs/build.sh
```

### Translations

Translations are sourced from [Crowdin](https://docusaurus.io/docs/i18n/crowdin)
and generated when master is built.
For local development use the following two commands in the `docs` directory.

To download the newest Documentation translations run:

```sh
npm run crowdin:download
```

To upload changes from `src` & generate [explicit IDs](https://docusaurus.io/docs/markdown-features/headings#explicit-ids):

```shell
npm run crowdin:upload
```

### CI Build Flow

The docs are built and published in Travis CI with the `docs/build.sh` script.
Expand Down
12 changes: 10 additions & 2 deletions docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ source ../ci/rust-version.sh
../ci/docker-run.sh "$rust_stable_docker_image" docs/convert-ascii-to-svg.sh
./set-solana-release-tag.sh

# Get current channel
eval "$(../ci/channel-info.sh)"

# Synchronize translations with Crowdin only on stable channel
if [ "$CHANNEL" = stable ]; then
echo "Downloading & updating translations..."
npm run crowdin:download
npm run crowdin:upload
fi

# Build from /src into /build
npm run build
echo $?

eval "$(../ci/channel-info.sh)"

# Publish only from merge commits and beta release tags
if [[ -n $CI ]]; then
if [[ -z $CI_PULL_REQUEST ]]; then
Expand Down
16 changes: 16 additions & 0 deletions docs/crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
project_id: '2'
api_token_env: 'CROWDIN_PERSONAL_TOKEN'
base_url: 'https://solana.crowdin.com'
preserve_hierarchy: true
files: [
# JSON translation files
# {
# source: '/i18n/en/**/*',
# translation: '/i18n/%two_letters_code%/**/%original_file_name%',
#},
# Docs Markdown files
{
source: '/src/**/*.md',
translation: '/i18n/%two_letters_code%/docusaurus-plugin-content-docs/current/**/%original_file_name%',
},
]
29 changes: 25 additions & 4 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,29 @@ module.exports = {
},
],
i18n: {
defaultLocale: 'en',
locales: ['en', 'zh'],
defaultLocale: "en",
locales: ["en", "de", "es", "ru", "ar"],
// localesNotBuilding: ["ko", "pt", "vi", "zh", "ja"],
localeConfigs: {
en: {
label: "English",
},
ru: {
label: "Русский",
},
es: {
label: "Español",
},
de: {
label: "Deutsch",
},
ar: {
label: "العربية",
},
ko: {
label: "한국어",
},
},
},
themeConfig: {
navbar: {
Expand Down Expand Up @@ -57,8 +78,8 @@ module.exports = {
position: "left",
},
{
type: 'localeDropdown',
position: 'right',
type: "localeDropdown",
position: "right",
},
{
href: "https://discordapp.com/invite/pquxPsq",
Expand Down
50 changes: 0 additions & 50 deletions docs/i18n/zh/code.json

This file was deleted.

110 changes: 0 additions & 110 deletions docs/i18n/zh/docusaurus-plugin-content-docs/current.json

This file was deleted.

16 changes: 0 additions & 16 deletions docs/i18n/zh/docusaurus-plugin-content-docs/current/cli.md

This file was deleted.

This file was deleted.

Loading

0 comments on commit 53c91ee

Please sign in to comment.