Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ envrc=$(find_up .envrc)
export ROOT_DIR=${envrc%/.envrc}

export REFS_JA_PATH=$PWD/translation/refs.ja.yaml

export USE_GUIX=yes
74 changes: 74 additions & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and deploy to GitHub Pages
on:
push:
branches: [ "ja" ]
pull_request:
workflow_dispatch:

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5

- name: Install dependencies
run: |
sudo apt update
sudo apt install --yes \
lua5.3 luarocks liblua5.3-dev libyaml-dev libcmark-dev cpanminus po4a

- name: Install CommonMark Perl module
run: |
sudo cpanm CommonMark

- name: Install LuaRocks
run: |
./translation/bin/install

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'

- name: Build pages
# Run twice to correctly reflect link references
run: |
eval "$(luarocks path --bin)"
export REFS_JA_PATH=$PWD/translation/refs.ja.yaml
echo "---\n" > translation/refs.translatable.yaml
git clone https://github.com/mquinson/po4a
export PERL5LIB="$PWD/po4a/lib:$PERL5LIB"
export PATH="$PWD/po4a:$PATH"
make --directory translation
touch translation/po4a.cfg
make --directory translation
mkdir -p tmp-for-github-pages
mv translation/ja/spec.html tmp-for-github-pages/

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: tmp-for-github-pages

deploy:
if: github.ref == 'refs/heads/ja'
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
permissions:
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
12 changes: 6 additions & 6 deletions tools/make_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ local lyaml = require('lyaml')

local format = arg[1] or 'html'

-- io.stderr:write(os.getenv("PWD"))
local jarefs = {}
local jarefs_file = io.open(os.getenv("REFS_JA_PATH", "r"))
if not jarefs_file then
io.stderr:write("WARNING: ja refs file not open\n")
os.exit(1)
if jarefs_file then
jarefs = lyaml.load(jarefs_file:read("a"))
jarefs_file:close()
else
io.stderr:write("WARNING: ja refs file not open. Please rerun\n")
end
local jarefs = lyaml.load(jarefs_file:read("a")) or {}
jarefs_file:close()

local trim = function(s)
return s:gsub("^%s+",""):gsub("%s+$","")
Expand Down
5 changes: 2 additions & 3 deletions translation/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PO4A ?= po4a
outdir := ja

all: ${outdir}/spec.txt \
Expand All @@ -6,8 +7,6 @@ all: ${outdir}/spec.txt \
ja/tools/make_spec.lua \
refs.ja.yaml
${MAKE} --directory ja spec.html
ssh pi mkdir -p /srv/www/CommonMark
rsync -av ./ja/spec.html pi:/srv/www/CommonMark/spec.html
.PHONY: all

ja/tools/make_spec.lua: ../tools/make_spec.lua
Expand All @@ -27,7 +26,7 @@ ${outdir}/spec.txt: po/ja.po po/en.pot po4a.cfg
translate: credit.md
cp ../spec.txt spec.txt
lua ../tools/make_spec.lua refblock < ../spec.txt >> spec.txt
po4a po4a.cfg
$(PO4A) po4a.cfg
.PHONY: translate

po/en.pot:
Expand Down
9 changes: 8 additions & 1 deletion translation/bin/install
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/sh
set -eu

luarocks install --local lcmark
luarocks install --local lyaml "YAML_LIBDIR=$YAML_LIBDIR"

if [ "${USE_GUIX:-}" = yes ]
then
luarocks install --local lyaml "YAML_LIBDIR=$YAML_LIBDIR"
else
luarocks install --local lyaml
fi
8 changes: 6 additions & 2 deletions translation/generate-translated-refs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env ruby
require "yaml"

doc = YAML.load_file(File.join(__dir__, "refs.translatable.ja.yaml"))
doc = {}
path = File.join(__dir__, "refs.translatable.ja.yaml")
if File.file?(path)
doc.replace(YAML.load_file(path))
end
refs = {}
doc&.each do |entry|
doc.each do |entry|
# entry has en, id, ja
ja = entry["ja"]
refs[ja] and raise "duplicated entry: #{entry.inspect}"
Expand Down
Loading
Loading