Skip to content

Commit 5db06a5

Browse files
committedMay 18, 2021
Make basic translation flow work
1 parent f5ecbaa commit 5db06a5

14 files changed

+158
-142
lines changed
 

‎.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ charset = utf-8
55
end_of_line = lf
66
insert_final_newline = true
77
indent_style = space
8-
indent_size = 2
8+
indent_size = 4
99

1010
[*.{yml,yaml}]
1111
indent_size = 2

‎.github/workflows/build.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ jobs:
2727
uses: actions/checkout@v2
2828
with:
2929
fetch-depth: 0 # all history (required for getting last modified time of files)
30-
- name: Cache bundle directory
31-
uses: actions/cache@v2
32-
with:
33-
path: vendor/bundle
34-
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
3530
- name: Setup build env
3631
run: |
3732
bin/setup-build-env
@@ -82,8 +77,8 @@ jobs:
8277
- name: Apply override files
8378
run: bin/exec-override
8479

85-
- name: Exec jekyll
86-
run: bin/exec-jekyll
80+
- name: Exec antora
81+
run: bin/exec-antora
8782

8883
- name: Deploy to GitHub Pages
8984
run: |

‎.github/workflows/pull-request.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ jobs:
1919
run: |
2020
rm -rf l10n
2121
cp -r merged/l10n ./
22-
- name: Cache bundle directory
23-
uses: actions/cache@v2
24-
with:
25-
path: vendor/bundle
26-
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
2722
- name: Setup build env
2823
run: |
2924
bin/setup-build-env
@@ -35,8 +30,8 @@ jobs:
3530
run: bin/exec-po4a-translate
3631
- name: Apply override files
3732
run: bin/exec-override
38-
- name: Exec jekyll
39-
run: bin/exec-jekyll
33+
- name: Exec antora
34+
run: bin/exec-antora
4035
- name: Deploy to surge
4136
run: |
4237
surge docs pr-preview-"${{ github.event.pull_request.number }}"-ja-quarkusio.surge.sh

‎.github/workflows/test-deploy.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: pull-request
2+
3+
on:
4+
workflow_dispatch:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
deploy-ja-to-surge:
10+
name: Deploy Japanese translation to surge.sh
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Checkout base branch
14+
uses: actions/checkout@v2
15+
- name: Setup build env
16+
run: |
17+
bin/setup-build-env
18+
- name: Configure git
19+
run: |
20+
bin/configure-git
21+
22+
- name: Exec po4a-translate
23+
run: bin/exec-po4a-translate
24+
- name: Apply override files
25+
run: bin/exec-override
26+
- name: Exec antora
27+
run: bin/exec-antora
28+
- name: Deploy to surge
29+
run: |
30+
surge docs camel-ja.surge.sh --token ${{ secrets.SURGE_TOKEN }}

‎Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# build
2+
run-update:
3+
act --reuse --job update
4+
5+
# sync
6+
run-sync:
7+
act --reuse --job sync
8+
9+
# test-deploy
10+
run-deploy-ja-to-surge:
11+
act --reuse --job deploy-ja-to-surge

‎bin/exec-antora

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
SCRIPT_DIR=$(cd $(dirname $0); pwd)
5+
L10N_HOME=$(cd $(dirname $SCRIPT_DIR); pwd)
6+
cd $L10N_HOME
7+
8+
source config/l10n-kit.conf
9+
10+
cd $L10N_HOME/translated/$TARGET_LANG
11+
12+
yarn build-all
13+
mkdir -p $L10N_HOME/docs
14+
cp -r public/* $L10N_HOME/docs/
15+
16+
# surge publish limit is 4500 files and about 430MB
17+
cat <<EOF > $L10N_HOME/docs/.surgeignore
18+
components/2.x
19+
components/3.4.x
20+
components/3.7.x
21+
components/3.9.x
22+
camel-kafka-connector
23+
EOF

‎bin/exec-jekyll-serve ‎bin/exec-antora-preview

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ source config/l10n-kit.conf
99

1010
cd $L10N_HOME/translated/$TARGET_LANG
1111

12-
bundle config set --local path "$L10N_HOME/vendor/bundle"
13-
bundle install
14-
bundle exec jekyll serve -d $L10N_HOME/docs/
12+
yarn build-all
13+
yarn preview

‎bin/exec-jekyll

-16
This file was deleted.

‎bin/exec-po4a-translate

+28-52
Original file line numberDiff line numberDiff line change
@@ -11,72 +11,48 @@ rm -rf $L10N_HOME/translated/$TARGET_LANG
1111
mkdir -p $L10N_HOME/translated
1212
cp -p -R $L10N_HOME/upstream $L10N_HOME/translated/$TARGET_LANG
1313

14-
for ITEM in `\find upstream -name "*.adoc"`; do
15-
if [ -f $ITEM ] ; then
16-
RELATIVE_FILE_PATH=`echo $ITEM | sed -e "s|^upstream\/||"`
17-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
14+
function po4a-translate() {
15+
local item=$1
16+
local format=$2
17+
shift # $1
18+
shift # $2
19+
20+
local relative_file_path=`echo $item | sed -e "s|^upstream\/||"`
21+
local relative_file_dir=$(dirname $relative_file_path);
22+
23+
if [ -f "l10n/po/$TARGET_LANG/$relative_file_path.po" ] ; then
24+
local localized="translated/$TARGET_LANG/$relative_file_path"
25+
echo "Processing $localized"
26+
27+
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$relative_file_dir"
28+
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-translate --master-charset UTF-8 --localized-charset UTF-8 -f $format $@ --keep 0 --master "upstream/$relative_file_path" --localized $localized --po "l10n/po/$TARGET_LANG/$relative_file_path.po"
1829

19-
if [ -f "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po" ] ; then
20-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
21-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-translate --master-charset UTF-8 --localized-charset UTF-8 -f asciidoc -o tablecells --keep 0 --master "upstream/$RELATIVE_FILE_PATH" --localized "translated/$TARGET_LANG/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
30+
if [ "$format" = "asciidoc" ] || [ "$format" = "text" ] ; then
31+
# fix po4a handling of list values in YAML Front Matter
32+
./bin/fix-yaml-front-matter "$localized"
2233
fi
2334
fi
24-
done
35+
}
2536

26-
for ITEM in `\find upstream -name "*.md"`; do
37+
for ITEM in `\find upstream/content -name "*.adoc"`; do
2738
if [ -f $ITEM ] ; then
28-
RELATIVE_FILE_PATH=`echo $ITEM | sed -e "s|^upstream\/||"`
29-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
30-
31-
if [ -f "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po" ] ; then
32-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
33-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-translate --master-charset UTF-8 --localized-charset UTF-8 -f text -o markdown -o neverwrap --keep 0 --master "upstream/$RELATIVE_FILE_PATH" --localized "translated/$TARGET_LANG/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
34-
fi
39+
po4a-translate $ITEM asciidoc -o tablecells
3540
fi
3641
done
3742

38-
YAML_FILES=(
39-
"_data/guides-1-7.yaml"
40-
"_data/guides-1-11.yaml"
41-
"_data/guides-latest.yaml"
42-
)
43-
44-
for ITEM in ${YAML_FILES[@]} ; do
45-
ABSOLUTE_FILE_PATH="$L10N_HOME/upstream/$ITEM"
46-
if [ -f $ABSOLUTE_FILE_PATH ] ; then
47-
RELATIVE_FILE_PATH=$ITEM
48-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
49-
50-
if [ -f "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po" ] ; then
51-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
52-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-translate --master-charset UTF-8 --localized-charset UTF-8 -f yaml --keep 0 --master "upstream/$RELATIVE_FILE_PATH" --localized "translated/$TARGET_LANG/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
53-
fi
43+
for ITEM in `\find upstream/content -name "*.md"`; do
44+
if [ -f $ITEM ] ; then
45+
# target only specified headers from YAML Front Matter
46+
po4a-translate $ITEM text -o markdown -o neverwrap -o yfm_keys=title,preview,description -o yfm_skip_array
5447
fi
5548
done
5649

5750
HTML_FILES=(
58-
"_includes/community-contrib-band.html"
59-
"_includes/feedback-community-band.html"
60-
"_includes/get-started-band.html"
61-
"_includes/homepage-container_first-band.html"
62-
"_includes/homepage-developer_joy-band.html"
63-
"_includes/homepage-extensions-band.html"
64-
"_includes/homepage-hero-band.html"
65-
"_includes/support-help-band.html"
66-
"_includes/support-options-band.html"
67-
"_includes/worldtour-abstracts.html"
68-
"_includes/worldtour-code.html"
51+
"layouts/index.html"
6952
)
7053

7154
for ITEM in ${HTML_FILES[@]} ; do
72-
ABSOLUTE_FILE_PATH="$L10N_HOME/upstream/$ITEM"
73-
if [ -f $ABSOLUTE_FILE_PATH ] ; then
74-
RELATIVE_FILE_PATH=$ITEM
75-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
76-
77-
if [ -f "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po" ] ; then
78-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
79-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-translate --master-charset UTF-8 --localized-charset UTF-8 -f xhtml --keep 0 --master "upstream/$RELATIVE_FILE_PATH" --localized "translated/$TARGET_LANG/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
80-
fi
55+
if [ -f "$L10N_HOME/upstream/$ITEM" ] ; then
56+
po4a-translate "upstream/$ITEM" xhtml
8157
fi
8258
done

‎bin/exec-po4a-updatepo

+22-53
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,39 @@ cd $L10N_HOME
77

88
source config/l10n-kit.conf
99

10-
for ITEM in `\find upstream -name "*.adoc"`; do
10+
function po4a-updatepo() {
11+
local item=$1
12+
local format=$2
13+
shift # $1
14+
shift # $2
1115

12-
if [ -f $ITEM ] ; then
13-
RELATIVE_FILE_PATH=`echo $ITEM | sed -e "s|^upstream\/||"`
14-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
15-
16-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
17-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-updatepo --master-charset UTF-8 -f asciidoc -o tablecells --master "upstream/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
18-
msgcat --to-code=utf-8 --no-wrap -o l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po
19-
fi
20-
done
16+
local relative_file_path=`echo $item | sed -e "s|^upstream\/||"`
17+
local relative_file_dir=$(dirname $relative_file_path)
2118

22-
for ITEM in `\find upstream -name "*.md"`; do
19+
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$relative_file_dir"
20+
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-updatepo --master-charset UTF-8 -f $format $@ --master "upstream/$relative_file_path" --po "l10n/po/$TARGET_LANG/$relative_file_path.po"
21+
msgcat --to-code=utf-8 --no-wrap -o l10n/po/$TARGET_LANG/$relative_file_path.po l10n/po/$TARGET_LANG/$relative_file_path.po
22+
}
2323

24+
for ITEM in `\find upstream/content -name "*.adoc"`; do
2425
if [ -f $ITEM ] ; then
25-
RELATIVE_FILE_PATH=`echo $ITEM | sed -e "s|^upstream\/||"`
26-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
27-
28-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
29-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-updatepo --master-charset UTF-8 -f text -o markdown -o neverwrap --master "upstream/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
30-
msgcat --to-code=utf-8 --no-wrap -o l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po
26+
po4a-updatepo $ITEM asciidoc -o tablecells
3127
fi
3228
done
3329

34-
YAML_FILES=(
35-
"_data/guides-1-7.yaml"
36-
"_data/guides-1-11.yaml"
37-
"_data/guides-latest.yaml"
38-
)
39-
40-
for ITEM in ${YAML_FILES[@]} ; do
41-
ABSOLUTE_FILE_PATH="$L10N_HOME/upstream/$ITEM"
42-
if [ -f $ABSOLUTE_FILE_PATH ] ; then
43-
RELATIVE_FILE_PATH=$ITEM
44-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
45-
46-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
47-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-updatepo --master-charset UTF-8 -f yaml --master "upstream/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
48-
msgcat --to-code=utf-8 --no-wrap -o l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po
30+
for ITEM in `\find upstream/content -name "*.md"`; do
31+
if [ -f $ITEM ] ; then
32+
# target only specified headers from YAML Front Matter
33+
po4a-updatepo $ITEM text -o markdown -o neverwrap -o yfm_keys=title,preview,description -o yfm_skip_array
4934
fi
5035
done
5136

5237
HTML_FILES=(
53-
"_includes/community-contrib-band.html"
54-
"_includes/feedback-community-band.html"
55-
"_includes/get-started-band.html"
56-
"_includes/homepage-container_first-band.html"
57-
"_includes/homepage-developer_joy-band.html"
58-
"_includes/homepage-extensions-band.html"
59-
"_includes/homepage-hero-band.html"
60-
"_includes/support-help-band.html"
61-
"_includes/support-options-band.html"
62-
"_includes/worldtour-abstracts.html"
63-
"_includes/worldtour-code.html"
38+
"layouts/index.html"
6439
)
6540

66-
for ITEM in ${HTML_FILES[@]} ; do
67-
ABSOLUTE_FILE_PATH="$L10N_HOME/upstream/$ITEM"
68-
if [ -f $ABSOLUTE_FILE_PATH ] ; then
69-
RELATIVE_FILE_PATH=$ITEM
70-
RELATIVE_FILE_DIR=$(dirname $RELATIVE_FILE_PATH);
71-
72-
mkdir -p "$L10N_HOME/l10n/po/$TARGET_LANG/$RELATIVE_FILE_DIR"
73-
PERLLIB=vendor/po4a/lib vendor/po4a/po4a-updatepo --master-charset UTF-8 -f xhtml --master "upstream/$RELATIVE_FILE_PATH" --po "l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po"
74-
msgcat --to-code=utf-8 --no-wrap -o l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po l10n/po/$TARGET_LANG/$RELATIVE_FILE_PATH.po
41+
for ITEM in ${HTML_FILES[@]} ; do
42+
if [ -f "$L10N_HOME/upstream/$ITEM" ] ; then
43+
po4a-updatepo "upstream/$ITEM" xhtml
7544
fi
76-
done
45+
done

‎bin/fix-yaml-front-matter

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
This script is to remove wrong single quotes (') from values in YAML Front
5+
Matter which are originally a list of values. This is a workaround to the po4a
6+
issue:
7+
https://github.com/mquinson/po4a/issues/255
8+
"""
9+
10+
import os
11+
import sys
12+
import frontmatter
13+
14+
if len(sys.argv) < 2:
15+
print(f'''
16+
Usage: {os.path.basename(sys.argv[0])} <file_path>
17+
''')
18+
exit()
19+
20+
file_path = sys.argv[1]
21+
22+
target_keys = ['authors', 'categories']
23+
24+
text = frontmatter.load(file_path)
25+
26+
for key in target_keys:
27+
value = text.get(key)
28+
if type(value) is str and value.startswith('['):
29+
text[key] = list(map(
30+
lambda s: s.strip(' "'),
31+
value.strip('[]').split(',')))
32+
33+
with open(file_path, mode='wb') as file:
34+
frontmatter.dump(text, file, width=1000)

‎bin/setup-build-env

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
1212

1313
sudo apt-get update
1414
sudo apt-get -y install python3-pip git nodejs po4a
15-
sudo pip3 install translate-toolkit Python-Levenshtein
15+
sudo pip3 install translate-toolkit Python-Levenshtein python-frontmatter
1616
npm install --global yarn
1717
yarn global add surge
1818

‎bin/sync-submodule

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ source config/l10n-kit.conf
1010
cd $L10N_HOME/upstream
1111

1212
git fetch
13-
git reset --hard origin/master
13+
git reset --hard origin/main
1414

1515
cd $L10N_HOME

‎upstream

Submodule upstream updated 83 files

0 commit comments

Comments
 (0)
Please sign in to comment.