Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i18n support #722

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 50 additions & 19 deletions .github/workflows/gh-pages.yaml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(remark for myself, do not mark this comment as resolved) @fzyzcjy should find a place (e.g. a header in zh version?) to let readers know this doc is translated by @trdthg

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continuing this thread: @trdthg - what about adding this information at the top of each zh page, saying something like:

This page is translated by [@trdthg](https://github.com/trdthg)

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: GitHub Pages

on:
workflow_dispatch: {}
push:
branches:
- master
Expand All @@ -11,28 +10,60 @@ on:
paths:
- 'book/**'

permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: pages
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
# Update the language picker in index.hbs to link new languages.
LANGUAGES: zh
fzyzcjy marked this conversation as resolved.
Show resolved Hide resolved

jobs:
deploy:
runs-on: ubuntu-20.04
fzyzcjy marked this conversation as resolved.
Show resolved Hide resolved
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

# ref https://github.com/peaceiris/actions-mdbook
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'

- name: Setup `mdbook-mermaid`
run: cargo install mdbook-mermaid
- name: Setup Rust cache
uses: ./.github/workflows/setup-rust-cache

- run: mdbook build ./book
- name: Install mdbook
uses: ./.github/workflows/install-mdbook

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }}
- name: Build course in English
working-directory: ./book
run: mdbook build -d book

- name: Build all translations
working-directory: ./book
run: |
for po_lang in ${{ env.LANGUAGES }}; do
echo "::group::Building $po_lang translation"
MDBOOK_BOOK__LANGUAGE=$po_lang \
MDBOOK_OUTPUT__HTML__SITE_URL=/flutter-rust-bridge/$po_lang/ \
mdbook build -d book/$po_lang
echo "::endgroup::"
done

- name: Setup Pages
uses: actions/configure-pages@v2

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/book
path: book/book

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
18 changes: 18 additions & 0 deletions .github/workflows/install-mdbook/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Install mdbook and dependencies

description: Install mdbook with the dependencies we need.

runs:
fzyzcjy marked this conversation as resolved.
Show resolved Hide resolved
using: composite
steps:
- name: Install mdbook
run: cargo install mdbook --locked --version 0.4.28
shell: bash

- name: Install mdbook-mermaid
run: cargo install mdbook-mermaid --locked --version 0.12.6
shell: bash

- name: Install mdbook-i18n-helpers
run: cargo install mdbook-i18n-helpers --locked --version 0.1.0
shell: bash
9 changes: 9 additions & 0 deletions .github/workflows/setup-rust-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Setup Rust cache
fzyzcjy marked this conversation as resolved.
Show resolved Hide resolved

description: Configure the rust-cache workflow.

runs:
using: composite
steps:
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
4 changes: 4 additions & 0 deletions book/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
book

# Translation artifacts
po/messages.pot
po/*.mo
12 changes: 12 additions & 0 deletions book/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ multilingual = false
src = "src"
title = "flutter_rust_bridge"

[build]
extra-watch-dirs = ["po"]

[preprocessor]

[preprocessor.mermaid]
command = "mdbook-mermaid"

[preprocessor.gettext]
after = ["links"]

[output.html]
curly-quotes = true
additional-css = ["theme/lang-popup.css"]
git-repository-url = "https://github.com/fzyzcjy/flutter_rust_bridge"
edit-url-template = "https://github.com/fzyzcjy/flutter_rust_bridge/edit/master/book/{path}"
Loading