From fc794694b1d83d6856b36ea08df69c2a0861d030 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 10 Apr 2023 14:12:12 -0300 Subject: v2: to translated version in --- v2/src/bin/conf | 12 ++++++++---- v2/src/bin/i18n | 18 ++++++++++++++---- v2/src/bin/index | 12 ++++++++++-- v2/src/lib/preamble.html | 10 +++++----- 4 files changed, 37 insertions(+), 15 deletions(-) (limited to 'v2') diff --git a/v2/src/bin/conf b/v2/src/bin/conf index e4dba61..3b56dbd 100755 --- a/v2/src/bin/conf +++ b/v2/src/bin/conf @@ -155,17 +155,21 @@ if [ -z "${title:-}" ]; then fi if [ -r "$FILENAME".i18n ]; then - translations="$(cat <<-EOF + translations_head="$(awk -F: -v lang="$lang" '$1 != lang{ + printf " \n", + $3, $1 + }' "$FILENAME".i18n)" + translations_body="$(cat <<-EOF EOF )" - printf 'export translations_html="%s"\n' "$(shesc "$translations")" + printf 'export translations_head_html="%s"\n' "$(shesc "$translations_head")" + printf 'export translations_body_html="%s"\n' "$(shesc "$translations_body")" fi if [ -n "${date:-}" ]; then diff --git a/v2/src/bin/i18n b/v2/src/bin/i18n index 76e07e7..30404eb 100755 --- a/v2/src/bin/i18n +++ b/v2/src/bin/i18n @@ -75,11 +75,21 @@ awk ' END { for (k1 in idx) { + split(idx[k1][0], b, /:/) + base = b[2] ".i18n" for (k2 in idx[k1]) { - split(idx[k1][k2], a, /:/) - file = a[2] ".i18n" - for (k3 in idx[k1]) { - print idx[k1][k3] > file + split(idx[k1][k2], f, /:/) + file = f[2] ".i18n" + if (k2 == 0) { + for (k3 in idx[k1]) { + "url-for " f[2] | getline url + print idx[k1][k3] ":" url > file + } + } else { + ret = system("cp " base " " file) + if (ret) { + exit ret + } } } } diff --git a/v2/src/bin/index b/v2/src/bin/index index 553cc27..36abd2e 100755 --- a/v2/src/bin/index +++ b/v2/src/bin/index @@ -85,7 +85,15 @@ index_category_title_html="$(eval "echo \"\$index_category_${collection}_title\" export url_absolute feed_url by_category_url title_html index_recent_title_html \ index_category_title_html -translations_html="$(cat <<-EOF +translations_head_html="$(langs | + awk -v lang="${lang:?}" -v coll="$collection" '$0 != lang { + "coll2path " $0 " " coll | getline coll_path + "url-for " $0 "/" coll_path | getline url + printf " \n", + url, $0 + }' +)" +translations_body_html="$(cat <<-EOF EOF )" -export translations_html +export translations_head_html translations_body_html diff --git a/v2/src/lib/preamble.html b/v2/src/lib/preamble.html index 1649bdd..c1e0592 100644 --- a/v2/src/lib/preamble.html +++ b/v2/src/lib/preamble.html @@ -5,16 +5,16 @@ + +$translations_head_html $title_html - + + - - -
@@ -35,7 +35,7 @@ $index_pastebin_title -$translations_html +$translations_body_html
-- cgit v1.2.3