aboutsummaryrefslogtreecommitdiff
path: root/v2/src/bin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xv2/src/bin/conf12
-rwxr-xr-xv2/src/bin/i18n18
-rwxr-xr-xv2/src/bin/index12
3 files changed, 32 insertions, 10 deletions
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 " <link rel=\"alternate\" type=\"text/html\" href=\"%s\" hreflang=\"%s\" />\n",
+ $3, $1
+ }' "$FILENAME".i18n)"
+ translations_body="$(cat <<-EOF
<ul class="translation-list">
$(awk -F: '{
- "url-for " $2 | getline url
printf " <li><a href=\"%s\">%s</a></li>\n",
- url, $1
+ $3, $1
}' "$FILENAME".i18n)
</ul>
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 " <link rel=\"alternate\" type=\"text/html\" href=\"%s\" hreflang=\"%s\" />\n",
+ url, $0
+ }'
+)"
+translations_body_html="$(cat <<-EOF
<ul class="translation-list">
$(langs | awk -v coll="$collection" '{
"coll2path " $0 " " coll | getline coll_path
@@ -95,7 +103,7 @@ translations_html="$(cat <<-EOF
</ul>
EOF
)"
-export translations_html
+export translations_head_html translations_body_html