diff --git a/CHANGELOG.md b/CHANGELOG.md index 9616eaa82fa4..012364ebb90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,27 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [1.14.1] - 2019-11-21 + +#### :bug: Bug Fix +* [#2022](https://github.com/facebook/docusaurus/pull/2022) fix(v1): markdown content and toc should render the same ([@endiliey](https://github.com/endiliey)) +* [#2020](https://github.com/facebook/docusaurus/pull/2020) fix(v1): docusaurus-start should work even if path contain 'pages' word ([@endiliey](https://github.com/endiliey)) +* [#2019](https://github.com/facebook/docusaurus/pull/2019) fix(v1): consistent slug & hash-link generation ([@endiliey](https://github.com/endiliey)) +* [#1869](https://github.com/facebook/docusaurus/pull/1869) fix(v1): fix page title render issue when referred by search result ([@parvezakkas](https://github.com/parvezakkas)) +* [#1895](https://github.com/facebook/docusaurus/pull/1895) fix(v1): mobile safari search input misalignment in header ([@sarneeh](https://github.com/sarneeh)) +* [#1871](https://github.com/facebook/docusaurus/pull/1871) misc(v1): use primary color for hovered items in table of contents ([@blitz137](https://github.com/blitz137)) + +#### :house: Internal +* [#1920](https://github.com/facebook/docusaurus/pull/1920) misc(v1): use Node.js lts version for docker ([@gengjiawen](https://github.com/gengjiawen)) + +#### :memo: Documentation +* [#1998](https://github.com/facebook/docusaurus/pull/1998) docs(v1): showcase user collective ([@kenning](https://github.com/kenning)) +* [#1961](https://github.com/facebook/docusaurus/pull/1961) docs(v1): remove exclusive language ([@ericcarboni](https://github.com/ericcarboni)) +* [#1873](https://github.com/facebook/docusaurus/pull/1873) docs: showcase user Amphora ([@xtellurian](https://github.com/xtellurian)) +* [#1918](https://github.com/facebook/docusaurus/pull/1918) docs(v1): showcase user Reactive Interaction Gateway ([@mmacai](https://github.com/mmacai)) +* [#1911](https://github.com/facebook/docusaurus/pull/1911) docs: updating configcat user link ([@mr-sige](https://github.com/mr-sige)) +* [#1902](https://github.com/facebook/docusaurus/pull/1902) misc: update URLs to non-HTML versions ([@ikrydev](https://github.com/ikrydev)) +* [#1901](https://github.com/facebook/docusaurus/pull/1901) docs(v1): remove broken link for user Vasern ([@ikrydev](https://github.com/ikrydev)) ## [1.14.0] - 2019-10-20 @@ -1178,7 +1198,8 @@ N/A - Blog - Documentation -[unreleased]: https://github.com/facebook/docusaurus/compare/v1.14.0...HEAD +[unreleased]: https://github.com/facebook/docusaurus/compare/v1.14.1...HEAD +[1.14.1]: https://github.com/facebook/docusaurus/compare/v1.14.0...v1.14.1 [1.14.0]: https://github.com/facebook/docusaurus/compare/v1.13.0...v1.14.0 [1.13.0]: https://github.com/facebook/docusaurus/compare/v1.12.0...v1.13.0 [1.12.0]: https://github.com/facebook/docusaurus/compare/v1.11.1...v1.12.0 diff --git a/website-1.x/versioned_docs/version-1.14.0/api-doc-markdown.md b/website-1.x/versioned_docs/version-1.14.1/api-doc-markdown.md similarity index 99% rename from website-1.x/versioned_docs/version-1.14.0/api-doc-markdown.md rename to website-1.x/versioned_docs/version-1.14.1/api-doc-markdown.md index 1e62d12e178d..84cc95356217 100644 --- a/website-1.x/versioned_docs/version-1.14.0/api-doc-markdown.md +++ b/website-1.x/versioned_docs/version-1.14.1/api-doc-markdown.md @@ -1,5 +1,5 @@ --- -id: version-1.14.0-doc-markdown +id: version-1.14.1-doc-markdown title: Markdown Features original_id: doc-markdown --- diff --git a/website-1.x/versioned_docs/version-1.14.0/api-site-config.md b/website-1.x/versioned_docs/version-1.14.1/api-site-config.md similarity index 99% rename from website-1.x/versioned_docs/version-1.14.0/api-site-config.md rename to website-1.x/versioned_docs/version-1.14.1/api-site-config.md index 806fafb0e33f..bcbbcad4e079 100644 --- a/website-1.x/versioned_docs/version-1.14.0/api-site-config.md +++ b/website-1.x/versioned_docs/version-1.14.1/api-site-config.md @@ -1,5 +1,5 @@ --- -id: version-1.14.0-site-config +id: version-1.14.1-site-config title: siteConfig.js original_id: site-config --- diff --git a/website-1.x/versioned_docs/version-1.14.0/getting-started-installation.md b/website-1.x/versioned_docs/version-1.14.1/getting-started-installation.md similarity index 97% rename from website-1.x/versioned_docs/version-1.14.0/getting-started-installation.md rename to website-1.x/versioned_docs/version-1.14.1/getting-started-installation.md index bfb43b685add..884366c3c61c 100644 --- a/website-1.x/versioned_docs/version-1.14.0/getting-started-installation.md +++ b/website-1.x/versioned_docs/version-1.14.1/getting-started-installation.md @@ -1,5 +1,5 @@ --- -id: version-1.14.0-installation +id: version-1.14.1-installation title: Installation description: Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly! original_id: installation @@ -9,7 +9,7 @@ Docusaurus was designed from the ground up to be easily installed and used to ge ## Installing Docusaurus -We have created an easy script that will get all of the infrastructure set up for you: +We have created a helpful script that will get all of the infrastructure set up for you: 1. Ensure you have the latest version of [Node](https://nodejs.org/en/download/) installed. We also recommend you install [Yarn](https://yarnpkg.com/en/docs/install) as well. diff --git a/website-1.x/versioned_docs/version-1.14.1/getting-started-publishing.md b/website-1.x/versioned_docs/version-1.14.1/getting-started-publishing.md new file mode 100644 index 000000000000..efee4da2b01f --- /dev/null +++ b/website-1.x/versioned_docs/version-1.14.1/getting-started-publishing.md @@ -0,0 +1,304 @@ +--- +id: version-1.14.1-publishing +title: Publishing your site +original_id: publishing +--- + +You should now have a [site up and running locally](getting-started-site-creation.md). Once you have [customized](api-site-config.md) it to your liking, it's time to publish it. Docusaurus generates a static HTML website that is ready to be served by your favorite web server or online hosting solution. + +## Building Static HTML Pages + +To create a static build of your website, run the following script from the `website` directory: + +```bash +yarn run build # or `npm run build` +``` + +This will generate a `build` directory inside the `website` directory containing the `.html` files from all of your docs and other pages included in `pages`. + +## Hosting Static HTML Pages + +At this point, you can grab all of the files inside the `website/build` directory and copy them over to your favorite web server's `html` directory. + +> For example, both Apache and Nginx serve content from `/var/www/html` by default. That said, choosing a web server or provider is outside the scope of Docusaurus. + +> When serving the site from your own web server, ensure the web server is serving the asset files with the proper HTTP headers. CSS files should be served with the `content-type` header of `text/css`. In the case of Nginx, this would mean setting `include /etc/nginx/mime.types;` in your `nginx.conf` file. See [this issue](https://github.com/facebook/docusaurus/issues/602) for more info. + +### Hosting on a Service: + +* [ZEIT Now](#using-zeit-now) +* [GitHub Pages](#using-github-pages) +* [Netlify](#hosting-on-netlify) +* [Render](#hosting-on-render) + +### Using ZEIT Now + +Deploying your Docusaurus project to [ZEIT Now](https://zeit.co/now) will provide you with [various benefits](https://zeit.co/now) in the areas of performance and ease of use. + +Most importantly, however, deploying a Docusaurus project only takes a couple seconds: + +1. First, install their [command-line interface](https://zeit.co/download): + +```bash +npm i -g now +``` + +2. Run a single command inside the root directory of your project: + +```bash +now +``` + +**That's all.** Your docs will automatically be deployed. + +### Using GitHub Pages + +Docusaurus was designed to work really well with one of the most popular hosting solutions for open source projects: [GitHub Pages](https://pages.github.com/). + +#### Deploying to GitHub Pages + +1. Docusaurus supports deploying as [project pages or user/organization pages](https://help.github.com/articles/user-organization-and-project-pages), your code repository does not even need to be public. + +> Even if your repository is private, anything published to a `gh-pages` branch will be [public](https://help.github.com/articles/user-organization-and-project-pages/). + +__Note:__ When you deploy as user/organization page, the publish script will deploy these sites to the root of the __`master`__ branch of the _username_.github.io repo. In this case, note that you will want to have the Docusaurus infra, your docs, etc. either in __another branch of the _username_.github.io repo__ (e.g., maybe call it `source`), or in another, separate repo (e.g. in the same as the documented source code). + +2. You will need to modify the file `website/siteConfig.js` and add the required parameters. + +| Name | Description | +| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `organizationName` | The GitHub user or organization that owns the repository. If you are the owner, then it is your GitHub username. In the case of Docusaurus, that would be the "_facebook_" GitHub organization. | +| `projectName` | The name of the GitHub repository for your project. For example, the source code for Docusaurus is hosted at https://github.com/facebook/docusaurus, so our project name in this case would be "docusaurus". | +| `url` | Your website's URL. For projects hosted on GitHub pages, this will be "https://_username_.github.io" | +| `baseUrl` | Base URL for your project. For projects hosted on GitHub pages, it follows the format "/_projectName_/". For https://github.com/facebook/docusaurus, `baseUrl` is `/docusaurus/`. | + + +```js +const siteConfig = { + ... + url: 'https://__userName__.github.io', // Your website URL + baseUrl: '/testProject/', + projectName: 'testProject', + organizationName: 'userName' + ... +} +``` + +In case you want to deploy as a user or organization site, specify the project name as `.github.io` or `.github.io`. E.g. If your GitHub username is "user42" then _user42.github.io_, or in the case of an organization name of "org123", it will be _org123.github.io_. + +__Note:__ Not setting the `url` and `baseUrl` of your project might result in incorrect file paths generated which can cause broken links to assets paths like stylesheets and images. + +> While we recommend setting the `projectName` and `organizationName` in `siteConfig.js`, you can also use environment variables `ORGANIZATION_NAME` and `PROJECT_NAME`. + +3. Now you have to specify the git user as an environment variable, and run the script [`publish-gh-pages`](./api-commands.md#docusaurus-publish) + +| Name | Description | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| `GIT_USER` | The username for a GitHub account that has commit access to this repo. For your own repositories, this will usually be your own GitHub username. The specified `GIT_USER` must have push access to the repository specified in the combination of `organizationName` and `projectName`. | + +To run the script directly from the command-line, you can use the following, filling in the parameter values as appropriate. + +**Bash** +```bash +GIT_USER= \ + CURRENT_BRANCH=master \ + USE_SSH=true \ + yarn run publish-gh-pages # or `npm run publish-gh-pages` +``` + +**Windows** +```batch +cmd /C "set GIT_USER= && set CURRENT_BRANCH=master && set USE_SSH=true && yarn run publish-gh-pages" +``` + +There are also two optional parameters that are set as environment variables: + +| Name | Description | +| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `USE_SSH` | If this is set to `true`, then SSH is used instead of HTTPS for the connection to the GitHub repo. HTTPS is the default if this variable is not set. | +| `CURRENT_BRANCH` | The branch that contains the latest docs changes that will be deployed. Usually, the branch will be `master`, but it could be any branch (default or otherwise) except for `gh-pages`. If nothing is set for this variable, then the current branch will be used. | + +If you run into issues related to SSH keys, visit [GitHub's authentication documentation](https://help.github.com/articles/connecting-to-github-with-ssh/). + +You should now be able to load your website by visiting its GitHub Pages URL, which could be something along the lines of https://_username_.github.io/_projectName_, or a custom domain if you have set that up. For example, Docusaurus' own GitHub Pages URL is https://facebook.github.io/Docusaurus because it is served from the `gh-pages` branch of the https://github.com/facebook/docusaurus GitHub repository. However, it can also be accessed via https://docusaurus.io/, via a generated `CNAME` file which can be configured via the `cname` [siteConfig option](api-site-config.md#cname-string). + +We highly encourage reading through the [GitHub Pages documentation](https://pages.github.com) to learn more about how this hosting solution works. + +You can run the command above any time you update the docs and wish to deploy the changes to your site. Running the script manually may be fine for sites where the documentation rarely changes and it is not too much of an inconvenience to remember to manually deploy changes. + +However, you can automate the publishing process with continuous integration (CI). + +## Automating Deployments Using Continuous Integration + +Continuous integration (CI) services are typically used to perform routine tasks whenever new commits are checked in to source control. These tasks can be any combination of running unit tests and integration tests, automating builds, publishing packages to NPM, and yes, deploying changes to your website. All you need to do to automate deployment of your website is to invoke the `publish-gh-pages` script whenever your docs get updated. In the following section, we'll be covering how to do just that using [CircleCI](https://circleci.com/), a popular continuous integration service provider. + +### Using CircleCI 2.0 + +If you haven't done so already, you can [setup CircleCI](https://circleci.com/signup/) for your open source project. Afterwards, in order to enable automatic deployment of your site and documentation via CircleCI, just configure Circle to run the `publish-gh-pages` script as part of the deployment step. You can follow the steps below to get that setup. + +1. Ensure the GitHub account that will be set as the `GIT_USER` has `write` access to the repository that contains the documentation, by checking `Settings | Collaborators & teams` in the repository. +1. Log into GitHub as the `GIT_USER`. +1. Go to https://github.com/settings/tokens for the `GIT_USER` and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/), granting it full control of private repositories through the `repository` access scope. Store this token in a safe place, making sure to not share it with anyone. This token can be used to authenticate GitHub actions on your behalf in place of your GitHub password. +1. Open your CircleCI dashboard, and navigate to the Settings page for your repository, then select "Environment variables". The URL looks like https://circleci.com/gh/ORG/REPO/edit#env-vars, where "ORG/REPO" should be replaced with your own GitHub organization/repository. +1. Create a new environment variable named `GITHUB_TOKEN`, using your newly generated access token as the value. +1. Create a `.circleci` directory and create a `config.yml` under that directory. +1. Copy the text below into `.circleci/config.yml`. + +```yaml +# If you only want circle to run on direct commits to master, you can uncomment this out +# and uncomment the filters: *filter-only-master down below too +# +# aliases: +# - &filter-only-master +# branches: +# only: +# - master + +version: 2 +jobs: + deploy-website: + docker: + # specify the version you desire here + - image: circleci/node:8.11.1 + + steps: + - checkout + - run: + name: Deploying to GitHub Pages + command: | + git config --global user.email "@users.noreply.github.com" + git config --global user.name "" + echo "machine github.com login password $GITHUB_TOKEN" > ~/.netrc + cd website && yarn install && GIT_USER= yarn run publish-gh-pages + +workflows: + version: 2 + build_and_deploy: + jobs: + - deploy-website: +# filters: *filter-only-master +``` + +Make sure to replace all `<....>` in the `command:` sequence with appropriate values. For ``, it should be a GitHub account that has access to push documentation to your GitHub repository. Many times `` and `` will be the same. + +**DO NOT** place the actual value of `$GITHUB_TOKEN` in `circle.yml`. We already configured that as an environment variable back in Step 5. + +> If you want to use SSH for your GitHub repository connection, you can set `USE_SSH=true`. So the above command would look something like: `cd website && npm install && GIT_USER= USE_SSH=true npm run publish-gh-pages`. + +> Unlike when you run the `publish-gh-pages` script manually when the script runs within the Circle environment, the value of `CURRENT_BRANCH` is already defined as an [environment variable within CircleCI](https://circleci.com/docs/1.0/environment-variables/) and will be picked up by the script automatically. + +Now, whenever a new commit lands in `master`, CircleCI will run your suite of tests and, if everything passes, your website will be deployed via the `publish-gh-pages` script. + +> If you would rather use a deploy key instead of a personal access token, you can by starting with the CircleCI [instructions](https://circleci.com/docs/1.0/adding-read-write-deployment-key/) for adding a read/write deploy key. + +### Tips & Tricks + +When initially deploying to a `gh-pages` branch using CircleCI, you may notice that some jobs triggered by commits to the `gh-pages` branch fail to run successfully due to a lack of tests (This can also result in chat/slack build failure notifications). + +You can work around this by: +- Setting the environment variable `CUSTOM_COMMIT_MESSAGE` flag to the `publish-gh-pages` command with the contents of `[skip ci]`. +e.g. +```bash +CUSTOM_COMMIT_MESSAGE="[skip ci]" \ + yarn run publish-gh-pages # or `npm run publish-gh-pages` +``` + +- Alternatively, you can work around this by creating a basic CircleCI config with the following contents: +```yaml +# CircleCI 2.0 Config File +# This config file will prevent tests from being run on the gh-pages branch. +version: 2 +jobs: + build: + machine: true + branches: + ignore: gh-pages + steps: + - run: echo "Skipping tests on gh-pages branch" +``` + +Save this file as `config.yml` and place it in a `.circleci` directory inside your `website/static` directory. + +### Using Travis CI + +1. Go to https://github.com/settings/tokens and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) +1. Using your GitHub account, [add the Travis CI app](https://github.com/marketplace/travis-ci) to the repository you want to activate. +1. Open your Travis CI dashboard. The URL looks like https://travis-ci.com/USERNAME/REPO, and navigate to the `More options` > `Setting` > `Environment Variables` section of your repository. +1. Create a new environment variable named `GH_TOKEN` with your newly generated token as its value, then `GH_EMAIL` (your email address) and `GH_NAME` (your GitHub username). +1. Create a `.travis.yml` on the root of your repository with below text. + +```yaml +# .travis.yml +language: node_js +node_js: + - '8' +branches: + only: + - master +cache: + yarn: true +script: + - git config --global user.name "${GH_NAME}" + - git config --global user.email "${GH_EMAIL}" + - echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc + - cd website && yarn install && GIT_USER="${GH_NAME}" yarn run publish-gh-pages +``` + +Now, whenever a new commit lands in `master`, Travis CI will run your suite of tests and, if everything passes, your website will be deployed via the `publish-gh-pages` script. + +### Hosting on ZEIT Now + +With [ZEIT Now](#using-zeit-now), you can deploy your site and connect it to [GitHub](https://zeit.co/github) or [GitLab](https://zeit.co/gitlab) to automatically receive a new deployment every time you push a commit. + +### Hosting on Netlify + +Steps to configure your Docusaurus-powered site on Netlify. + +1. Select **New site from Git** +1. Connect to your preferred Git provider. +1. Select the branch to deploy. Default is `master` +1. Configure your build steps: + + * For your build command enter: `cd website; npm install; npm run build;` + * For publish directory: `website/build/` (use the `projectName` from your `siteConfig`) + +1. Click **Deploy site** + +You can also configure Netlify to rebuild on every commit to your repository, or only `master` branch commits. + +### Hosting on Render + +Render offers free [static site](https://render.com/docs/static-sites) hosting with fully managed SSL, custom domains, a global CDN and continuous auto deploys from your Git repo. Deploy your app in just a few minutes by following these steps. + +1. Create a new **Web Service** on Render, and give Render's GitHub app permission to access your Docusaurus repo. + +2. Select the branch to deploy. The default is `master`. + +2. Enter the following values during creation. + + | Field | Value | + | ------- | ----- | + | **Environment** | `Static Site` | + | **Build Command** | `cd website; yarn install; yarn build` | + | **Publish Directory** | `website/build/` | + + `projectName` is the value you defined in your `siteConfig.js`. + + ```javascript{7} + const siteConfig = { + // ... + projectName: 'your-project-name', + // ... + ``` + +That's it! Your app will be live on your Render URL as soon as the build finishes. + +### Publishing to GitHub Enterprise + +GitHub enterprise installations should work in the same manner as github.com; you only need to identify the organization's GitHub Enterprise host. + +| Name | Description | +| ------------- | ---------------------------------------------- | +| `GITHUB_HOST` | The hostname for the GitHub enterprise server. | + +Alter your `siteConfig.js` to add a property `'githubHost'` which represents the GitHub Enterprise hostname. Alternatively, set an environment variable `GITHUB_HOST` when executing the publish command. diff --git a/website-1.x/versioned_docs/version-1.14.1/guides-translation.md b/website-1.x/versioned_docs/version-1.14.1/guides-translation.md new file mode 100644 index 000000000000..4821430db414 --- /dev/null +++ b/website-1.x/versioned_docs/version-1.14.1/guides-translation.md @@ -0,0 +1,303 @@ +--- +id: version-1.14.1-translation +title: Translations & Localization +original_id: translation +--- + +Docusaurus allows for useful translation functionality using [Crowdin](https://crowdin.com/). Documentation files written in English are uploaded to Crowdin for translation by users within a community. Top-level pages written with English strings can be translated by wrapping any strings you want to translate in a `` tag. Other titles and labels will also be found and properly translated. + +## Docusaurus Translation Configurations + +To generate example files for translations with Docusaurus, run the `examples` script with the command line argument `translations`: + +```bash +npm run examples translations +``` + +or + +```bash +yarn examples translations +``` + +This will create the following files: + +```bash +pages/en/help-with-translations.js +languages.js +../crowdin.yaml +``` + +* The `pages/en/help-with-translations.js` file includes the same starter help page generated by the `examples` script but now includes translation tags. + +> Generally, you will use `help-with-translations.js` as a guide to enable translations in your other pages, but not actually commit the file to your repo (i.e., you can delete it). However, if you want a Help page, and you currently do not have one, you can rename this file to `help.js` and use it as a starting point. + +* The `languages.js` file tells Docusaurus what languages you want to enable for your site. By default, we expect English to be enabled. + +* The `crowdin.yaml` file is used to configure Crowdin integration and is copied up one level into your Docusaurus project repo. If your Docusaurus project resides in `/project/website`, then `crowdin.yaml` will be copied to `/project/crowdin.yaml`. + +## Translating Your Existing Docs + +Your documentation files (e.g., the `.md` files that live in your `docs` directory) do not need to be changed or moved to support translations. They will be uploaded to Crowdin to be translated directly. + +## Enabling Translations on Pages + +Pages allow you to customize the layout and specific content of pages like a custom index page or help page. + +Pages with text that you want translated should be placed in `website/pages/en` directory. + +Wrap strings you want translated in a `` tag, and add the following `require` statement to the top of the file: + +```jsx +... +const translate = require('../../server/translate.js').translate; +... +

+ This header will be translated +

+... +``` + +You can also include an optional description attribute to give more context to a translator about how to translate the string: + +```jsx +

+ Rose +

+``` + +> The `` tag generally works well on pure strings. If you have a string like "Docusaurus currently provides support to help your website use [translations](${siteConfig.baseUrl}${siteConfig.docsUrl}/${this.props.language}/translation.html)", wrapping the `` tag around that entire string will cause issues because of the markdown linking, etc. Your options are to not translate those strings, or spread a bunch of `` tags amongst the pure substrings of that string. + +## Gathering Strings to Translate + +The strings within localized Pages must be extracted and provided to Crowdin. + +Add the following script to your `website/package.json` file, if it does not exist already: + +```js +{ + ... + "scripts": { + "write-translations": "docusaurus-write-translations" + }, + ... +} +``` + +Running the script will generate a `website/i18n/en.json` file containing all the strings that will be translated from English into other languages. + +The script will include text from the following places: + +* `title` and `sidebar_label` strings in document markdown headers +* category names in `sidebars.json` +* tagline in `siteConfig.js` +* header link `label` strings in `siteConfig.js` +* strings wrapped in the `` tag in any `.js` files inside `pages` + +### Custom Translation Strings + +If you want to add additional custom translation strings or override any of the strings that get produced by the script that creates the `website/i18n/en.json` file, you can add a `website/data/custom-translation-strings.json` file. The file should have a form of: + +```json +{ + "localized-strings": { + "docs": { + "id": { + "title": "string1", + "sidebar_label": "string2" + }, + "version-0.0.1-id": { + "title": "string3", + "sidebar_label": "string4" + } + } + }, + "pages-strings" : { + "id3": "string3", + "id4": "string4" + } +} +``` + +where `localized-strings` represent strings in your documentation content and `pages-strings` represents metadata in your documentation (e.g., title, links, etc). + +Here is an example: + +```json +{ + "_comment": "This file is used to provide custom strings for translations, including overriding defaults", + "localized-strings": { + "translation": "Translations and Localization" + }, + "pages-strings" : { + "Help Translate|recruit community translators for your project": "Help Us Translate" + } +} +``` + +See the generated `website/i18n/en.json` for an example. + +## How Strings Get Translated + +Docusaurus itself does not do any translation from one language to another. Instead, it integrates [Crowdin](https://crowdin.com/) to upload translations and then downloads the appropriately translated files from Crowdin. + +## How Docusaurus Uses String Translations + +This section provides context about how translations in Docusaurus works. + +### Strings + +A Docusaurus site has many strings used throughout it that require localization. However, maintaining a list of strings used throughout a site can be laborious. Docusaurus simplifies this by centralizing strings. + +The header navigation, for example, can have links to 'Home' or your 'Blog'. This and other strings found in the headers and sidebars of pages are extracted and placed into `i18n/en.json`. When your files are translated, say into Spanish, an `i18n/es-ES.json` file will be downloaded from Crowdin. Then, when the Spanish pages are generated, Docusaurus will replace the English version of corresponding strings with translated strings from the corresponding localized strings file (e.g. In a Spanish enabled site 'Help' will become 'Ayuda'). + +### Markdown Files + +For documentation files themselves, translated versions of these files are downloaded and then rendered through the proper layout template. + +### Other Pages + +For other pages, Docusaurus will automatically transform all `` tags it finds into function calls that return the translated strings from the corresponding localized file _`locale.json`_. + +## Crowdin + +Crowdin is a company that provides translation services. For Open Source projects, Crowdin provides free string translations. + +Create your translation project on [Crowdin](https://crowdin.com/). You can use [Crowdin's guides](https://support.crowdin.com/translation-process-overview/) to learn more about the translations work flow. _We suggest that you deselect and do not include "English" as a translatable language to prevent the creation of `en-US` localization files as this can lead to confusion._ + +> Ensure in your Crowdin settings, in the Translations section, that "Duplicate Strings" are set to ["Hide - all duplicates will share the same translation"](https://support.crowdin.com/api/create-project/). This setting will ensure that identical strings between versions share a single translation. + +Your project will need a `crowdin.yaml` file generated. If you ran `yarn examples translations` or `npm run examples translations`, this file was created for you on the same level as your `website` directory. + +> You will need to install the `crowdin` command line interface. Please follow the [installation directions](https://support.crowdin.com/cli-tool/). + +The example below can be automatically generated by the Docusaurus cli with the `examples` script. It should be placed in the top level of your project directory to configure how and what files are uploaded/downloaded. + +Below is an example Crowdin configuration for the respective languages: German, Spanish, French, Japanese, Korean, Bahasa Indonesia, Portuguese Brazilian, Chinese Simplified, and Chinese Traditional. + +```yaml +project_identifier_env: CROWDIN_DOCUSAURUS_PROJECT_ID +api_key_env: CROWDIN_DOCUSAURUS_API_KEY +base_path: "./" +preserve_hierarchy: true + +files: + - + source: '/docs/**/*.md' + translation: '/website/translated_docs/%locale%/**/%original_file_name%' + languages_mapping: &anchor + locale: + 'de': 'de' + 'es-ES': 'es-ES' + 'fr': 'fr' + 'ja': 'ja' + 'ko': 'ko' + 'mr': 'mr-IN' + 'pt-BR': 'pt-BR' + 'zh-CN': 'zh-CN' + 'zh-TW': 'zh-TW' +``` + +You can go [here](https://support.crowdin.com/configuration-file/) to learn more about customizing your `crowdin.yaml` file. + +### Setup the Crowdin Scripts + +You will want to manually sync your files to and from Crowdin. The sync process will upload any markdown files in `/docs` as well as translatable strings in `website/i18n/en.json`. (These strings can be generated by running `yarn write-translations`.) + +You can add the following to your `package.json` to manually trigger Crowdin. + +```js +"scripts": { + "crowdin-upload": "crowdin --config ../crowdin.yaml upload sources --auto-update -b master", + "crowdin-download": "crowdin --config ../crowdin.yaml download -b master" +}, +``` + +### Manual File Sync + +You will always want to upload your markdown files and translatable strings first and the download the translations section. So run the commands in this order: + +```bash +CROWDIN_DOCUSAURUS_PROJECT_ID=YOUR_CROWDIN_PROJECT_ID CROWDIN_DOCUSAURUS_API_KEY=YOUR_CROWDIN_API_KEY yarn run crowdin-upload +CROWDIN_DOCUSAURUS_PROJECT_ID=YOUR_CROWDIN_PROJECT_ID CROWDIN_DOCUSAURUS_API_KEY=YOUR_CROWDIN_API_KEY yarn run crowdin-download +``` + +> `YOUR_CROWDIN_PROJECT_ID` is the name of your Crowdin project. e.g., for https://crowdin.com/project/docusaurus/, that variable would be set to `docusaurus`. `YOUR_CROWDIN_API_KEY` is a unique key that is like a password. You can find it in the `API` tab of your Crowdin project's `Settings`. + +> These commands require having an environment variable set with your Crowdin project id and api key (`CROWDIN_PROJECT_ID`, `CROWDIN_API_KEY`). You can preface them inline as done above or add them permanently to your `.bashrc` or `.bash_profile`. + +> If you run more than one localized Docusaurus project on your computer, you should change the name of the environment variables to something unique (`CROWDIN_PROJECTNAME_PROJECT_ID`, `CROWDIN_PROJECTNAME_API_KEY`). + +> Since the files are generated, you do not need to have any files in your `website/i18n` or `website/translated_docs` directory as part of your repo. So you can can add `website/i18n/*` and `website/translated_docs` to your `.gitignore` file. + +### Automated File Sync Using CircleCI + +You can automate pulling down and uploading translations for your files using the [CircleCI](https://circleci.com) web continuous integration service. + +First, update the `.circleci/config.yml` file in your project directory to include steps to upload English files to be translated and download translated files using the Crowdin CLI. Here is an example `.circleci/config.yml` file: + +```yaml +# If you only want circle to run on direct commits to master, you can uncomment this out +# and uncomment the filters: *filter-only-master down below too +# +# aliases: +# - &filter-only-master +# branches: +# only: +# - master + +version: 2 +jobs: + deploy-website: + docker: + # specify the version you desire here + - image: circleci/node:8.11.1 + + steps: + - checkout + - run: + name: Deploying to GitHub Pages + command: | + git config --global user.email "@users.noreply.github.com" + git config --global user.name "" + echo "machine github.com login password $GITHUB_TOKEN" > ~/.netrc + # install Docusaurus and generate file of English strings + - cd website && yarn install && yarn run write-translations && cd .. + # crowdin install + - sudo apt-get install default-jre + - wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb + - sudo dpkg -i crowdin.deb + # translations upload/download + - crowdin --config crowdin.yaml upload sources --auto-update -b master + - crowdin --config crowdin.yaml download -b master + # build and publish website + cd website && GIT_USER= yarn run publish-gh-pages + +workflows: + version: 2 + build_and_deploy: + jobs: + - deploy-website: +# filters: *filter-only-master +``` + +The `crowdin` command uses the `crowdin.yaml` file generated with the `examples` script. It should be placed in your project directory to configure how and what files are uploaded/downloaded. + +Note that in the `crowdin.yaml` file, `CROWDIN_PROJECT_ID` and `CROWDIN_API_KEY` are environment variables set-up in Circle for your Crowdin project. They can be found in your Crowdin project settings. + +Now, Circle will help you automatically get translations prior to building your website. The provided `crowdin.yaml` file will copy translated documents into `website/translated_docs/`, and translated versions of the `i18n/en.json` strings file will into `i18n/${language}.json`. + +If you wish to use Crowdin on your machine locally, you can install the [Crowdin CLI tool](https://support.crowdin.com/cli-tool/) and run the same commands found in the `circle.yaml` file. The only difference is that you must set `project_identifier` and `api_key` values in the `crowdin.yaml` file since you will not have Circle environment variables set up. + +## Versioned Translations + +If you wish to have translation and versioning for your documentation, add the following section to the end of your `crowdin.yaml` file: + +```yaml + - + source: '/website/versioned_docs/**/*.md' + translation: '/website/translated_docs/%locale%/**/%original_file_name%' + languages_mapping: *anchor +``` + +Translated, versioned documents will be copied into `website/translated_docs/${language}/${version}/`. diff --git a/website-1.x/versions.json b/website-1.x/versions.json index 543bed753081..993de7d4090b 100644 --- a/website-1.x/versions.json +++ b/website-1.x/versions.json @@ -1,5 +1,5 @@ [ - "1.14.0", + "1.14.1", "1.13.0", "1.12.0", "1.11.x",