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

Update po4a scripts for better markdown support #873

Merged
merged 2 commits into from
Dec 22, 2022
Merged
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: 1 addition & 1 deletion .github/workflows/add-lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
id: cache-po4a
with:
path: "~/po4a"
key: ${{ runner.os }}-po4a
key: ${{ runner.os }}-po4a-0.68
Copy link
Member

Choose a reason for hiding this comment

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

You could use a hash like in the main repo to make the key unique

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uh, I had a look but don't have a clue how that works...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cache hasn't been used for a week, which means that any workflow run should now trigger the creation of a new one. So I could leave the key here as "po4a" and merge the new po4a version in the assets repo now. Does that sound ok @ann0see?

Copy link
Member

Choose a reason for hiding this comment

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

Use ${{ hashFiles('file1, 'file2') }}... Will open an issue for that soon.

- name: Install/retrieve po4a from cache
env:
CACHE_HIT: ${{ steps.cache-po4a.outputs.cache-hit }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jekyll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
id: cache-po4a
with:
path: "~/po4a"
key: ${{ runner.os }}-po4a
key: ${{ runner.os }}-po4a-0.68
- name: Install or retrieve po4a from cache
env:
CACHE_HIT: ${{steps.cache-po4a.outputs.cache-hit}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id: cache-po4a
with:
path: "~/po4a"
key: ${{ runner.os }}-po4a
key: ${{ runner.os }}-po4a-0.68
- name: Install or retrieve po4a from cache
env:
CACHE_HIT: ${{steps.cache-po4a.outputs.cache-hit}}
Expand Down
6 changes: 3 additions & 3 deletions _po4a-tools/po4a-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
if [[ "$CACHE_HIT" == 'true' ]] ; then
sudo cp --force --recursive ~/po4a/* /
else
sudo apt install -yq gettext libsgmls-perl libyaml-tiny-perl opensp
wget -O po4a.deb https://github.com/jamulussoftware/assets/raw/main/po4a/po4a_0.66.deb
sudo apt install -yq gettext libsgmls-perl libyaml-tiny-perl opensp libsyntax-keyword-try-perl
wget -O po4a.deb https://github.com/jamulussoftware/assets/raw/main/po4a/po4a_0.68.deb
Copy link
Member

Choose a reason for hiding this comment

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

Could you please upload the deb?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's in a PR in the assets repo. As I said in the description, I think #870 should be merged first, then the PR in assets, then this one. If I upload it now, the workflows won't find it.

sudo dpkg -i po4a.deb

if [ -f po4a.deb ] ; then
Expand All @@ -16,7 +16,7 @@ fi

mkdir -p ~/po4a

for dep in po4a libcroco3 libosp5 sgml-base gettext libsgmls-perl libyaml-tiny-perl opensp; do
for dep in po4a libcroco3 libosp5 sgml-base gettext libsgmls-perl libyaml-tiny-perl opensp libsyntax-keyword-try-perl; do
dpkg -L $dep | while IFS= read -r f; do if test -f $f; then echo $f; fi; done | xargs cp --parents --target-directory ~/po4a/
done
fi
10 changes: 6 additions & 4 deletions _po4a-tools/po4a-create-all-targets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ process_with_po4a () {
# Determine file format to be used
if [ $ext == yml ] ; then
FILE_FORMAT=yaml
OPTION="skip_array"
elif [ $ext == html ] ; then
FILE_FORMAT=xml
OPTION="ontagerror=warn"
elif [ $ext == md ] ; then
FILE_FORMAT=asciidoc
FILE_FORMAT=text
OPTION="markdown"
fi

# Run po4a-translate and create target files
Expand All @@ -116,6 +119,8 @@ process_with_po4a () {
--po "$PO_DIR/$lang/${filename}.po" \
--localized "$targ_doc" \
--localized-charset "UTF-8" \
--no-deprecation \
Copy link
Contributor Author

@ignotus666 ignotus666 Nov 16, 2022

Choose a reason for hiding this comment

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

This is to prevent a stream of warning messages - we use po4a in a way that is considered deprecated, but which actually works better for our workflow - we want separation between .po file updates and their processing into translated files. The 'updated' way of using po4a combines both steps, which we don't want.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. But will we need to change the behaviour any time soon?

Copy link
Contributor Author

@ignotus666 ignotus666 Nov 18, 2022

Choose a reason for hiding this comment

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

Not that I know of. In reality the "updated" way to use po4a is just an automated combined use of the scripts that we use separately.

--option "$OPTION" \
--keep "$THRESHOLD"

# Display message if translated file is created
Expand All @@ -134,6 +139,3 @@ while IFS= read -r -d '' dir ; do
echo "$lang":
process_with_po4a "$lang"
done < <(find "$PO_DIR" -mindepth 1 -maxdepth 1 -type d -print0)

# Produce a file with translation status of all .po files
source ./po4a-stats.sh
48 changes: 0 additions & 48 deletions _po4a-tools/po4a-stats.sh

This file was deleted.

7 changes: 6 additions & 1 deletion _po4a-tools/po4a-update-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ while IFS= read -r -d '' doc ; do
# Determine file format to be used
if [ $ext == yml ] ; then
FILE_FORMAT=yaml
OPTION="skip_array"
elif [ $ext == html ] ; then
FILE_FORMAT=xml
OPTION="ontagerror=warn"
elif [ $ext == md ] ; then
FILE_FORMAT=asciidoc
FILE_FORMAT=text
OPTION="markdown"
fi

# Update/create .po files
Expand All @@ -76,6 +79,8 @@ while IFS= read -r -d '' doc ; do
--master-charset "UTF-8" \
--msgmerge-opt --no-wrap \
--wrap-po newlines \
--no-deprecation \
--option "$OPTION" \
--po "$po_file" ; then
echo ''
echo Error updating "$lang" PO file for: "$filename".$ext
Expand Down