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

feat: remove fuzzy for zh_CN.po #3

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ indent_size = 2
max_line_length = 150

# Ignore paths
[{.git/**/*,LICENSE,**/Move.lock,mdbook-admonish.css,theme/**/*}]
[{.git/**/*,LICENSE,**/Move.lock,mdbook-admonish.css,theme/**/*,po/*}]
charset = unset
end_of_line = unset
indent_size = unset
Expand Down
9 changes: 9 additions & 0 deletions .github/actions/build-mdbook/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ runs:
env:
RUST_LOG: INFO
shell: bash

- name: Install mdbook-i18n-helpers
run: cargo install mdbook-i18n-helpers --locked --version 0.3.5
shell: bash

- name: Install i18n-report
run: cargo install i18n-report --locked --version 0.2.0
shell: bash

26 changes: 26 additions & 0 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# Usage: build.sh <book-lang> <dest-dir>
#
# Build the course as of the date specified specified in the
# POT-Creation-Date header of po/$book_lang.po. The output can be
# found in $dest_dir.
#

book_lang=${1:?"Usage: $0 <book-lang> <dest-dir>"}
dest_dir=${2:?"Usage: $0 <book-lang> <dest-dir>"}

if [ "$book_lang" = "en" ]; then
echo "::group::Building English course"
else
pot_creation_date=$(grep --max-count 1 '^"POT-Creation-Date:' "po/$book_lang.po" | sed -E 's/".*: (.*)\\n"/\1/')
pot_creation_date=${pot_creation_date:-now}
echo "::group::Building $book_lang translation as of $pot_creation_date"

export MDBOOK_BOOK__LANGUAGE=$book_lang
fi

mdbook build -d "$dest_dir"

echo "::endgroup::"
29 changes: 29 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,40 @@ jobs:
env:
# Colors don't seem to work properly with the multiline commands.
NO_COLOR: 1
# Update the language picker in index.hbs to link new languages.
LANGUAGES: zh_CN
steps:
- uses: actions/checkout@v4

- name: Install Gettext
run: |
sudo apt update
sudo apt install gettext

- uses: ./.github/actions/build-mdbook
with:
with_linkcheck: "false"

- name: Build course in English
run: .github/workflows/build.sh en build

- name: Build all translations
run: |
for po_lang in ${{ env.LANGUAGES }}; do
.github/workflows/build.sh $po_lang build/$po_lang
mv build/$po_lang/html build/html/$po_lang
done

- name: Build translation report
run: i18n-report report build/html/translation-report.html po/*.po

- name: Build synced translation report
run: |
cp -r po synced-po
MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages.pot", "granularity": 0}}' mdbook build -d synced-po
for file in synced-po/*.po; do msgmerge --update $file synced-po/messages.pot ; done
i18n-report report build/html/synced-translation-report.html synced-po/*.po

- uses: ./.github/actions/set-up-walrus
with:
SUI_ADDRESS: "${{ vars.SUI_ADDRESS }}"
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ __pycache__/
config.yml
working_dir
*.log
*~

# Walrus binary and configuration
walrus
!/contracts/walrus
examples/CONFIG/bin/walrus
./client_config.yaml
examples/CONFIG/config_dir/client_config.yaml

book/
po/*.po~
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ cargo install mdbook-i18n-helpers --locked
mdbook serve
```

### Using translated version
### Using translated versions

If there is a translated resource in `po/` directory, it can be specified through `MDBOOK_BOOK__LANGUAGE` like below:
If there is a translated resource in `po/` directory, it can be specified through the
`MDBOOK_BOOK__LANGUAGE` environment variable. For example, to build or serve the Chinese
translation:

```bash
MDBOOK_BOOK__LANGUAGE=zh_CN mdbook build
MDBOOK_BOOK__LANGUAGE=zh_CN mdbook serve
```

Please consult [TRANSLATING.md](./TRANSLATING.md) for further information on how to create and
maintain translations.

## Get help and report issues

If you have general questions or require help on how to use Walrus, please check for [existing
Expand Down
39 changes: 21 additions & 18 deletions TRANSLATING.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
# Translation Guidelines

## Translation workflow
The Walrus documentation uses [mdbook-i18n-helpers] as a translation framework.

### Preparation
## Preparation

RBE uses [mdbook-i18n-helpers](https://github.com/google/mdbook-i18n-helpers) as a translation framework.
The following tools are required.
The following tools are required:

* GNU gettext utilities ( `msgmerge` and `msgcat` )
* mdbook-i18n-helpers ( `cargo install mdbook-i18n-helpers` )
- GNU gettext utilities (`msgmerge` and `msgcat`)
- mdbook-i18n-helpers (`cargo install mdbook-i18n-helpers`)

### Creating and Updating Translations
## Creating and updating translations

Please see the [mdbook-i18n-helpers USAGE](https://github.com/google/mdbook-i18n-helpers/blob/main/i18n-helpers/USAGE.md) file for the detailed usage of mdbook-i18n-helpers.
The summarized command list is below:
Please see the [mdbook-i18n-helpers USAGE] file for the detailed usage of mdbook-i18n-helpers.
We summarize the most important commands below.

#### Generating a message template
### Generating a message template

The generated message templete `po/messages.pot` is required to create or update translations.
The generated message template `po/messages.pot` is required to create or update translations.

```bash
MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages.pot"}}' \
mdbook build -d po
MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages.pot"}}' mdbook build -d po
```

#### Creating a new translation resource
### Creating a new translation resource

`xx` is [ISO 639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code.
In the following, replace `xx` by the [ISO 639][iso_639] language code.

```bash
msginit -i po/messages.pot -l xx -o po/xx.po
```

#### Updating the existing translation resource
### Updating an existing translation resource

```bash
msgmerge --update po/xx.po po/messages.pot
```

### Editing translation resources
## Editing translation resources

After generating a translation resource `po/xx.po`, you can write translation messages in `msgstr` entry of `po/xx.po`.
After generating a translation resource `po/xx.po`, you can write translation messages
in `msgstr` entry of `po/xx.po`.
To build a translated book, the following command can be used.

```bash
MDBOOK_BOOK__LANGUAGE=xx mdbook build
MDBOOK_BOOK__LANGUAGE=xx mdbook serve
```

[mdbook-i18n-helpers]: https://github.com/google/mdbook-i18n-helpers
[mdbook-i18n-helpers USAGE]: https://github.com/google/mdbook-i18n-helpers/blob/main/i18n-helpers
[iso_639]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
7 changes: 5 additions & 2 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ src = "docs"
title = "Walrus"

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

[output.html]
theme = "theme"
additional-css = ["./mdbook-admonish.css"]
additional-css = [
"theme/css/mdbook-admonish.css",
"theme/css/language-picker.css",
]

[output.linkcheck]
optional = true
Expand Down
2 changes: 2 additions & 0 deletions docs/usage/web-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ may still be temporarily unavailable:
- `http://walrus.krates.ai:9000`
- `http://walrus-testnet.stakingdefenseleague.com:9000`
- `http://walrus.sui.thepassivetrust.com:9000`
- `http://walrus.globalstake.io:9000`

### Public publishers

Expand All @@ -94,6 +95,7 @@ may still be temporarily unavailable:
- `http://walrus-tn.juicystake.io:9090`
- `http://walrus-testnet.stakingdefenseleague.com:9001`
- `http://walrus.sui.thepassivetrust.com:9001`
- `http://walrus.globalstake.io:9001`

## HTTP API Usage

Expand Down
Loading