diff --git a/render.sh b/render.sh index dbaa74b..d01189c 100755 --- a/render.sh +++ b/render.sh @@ -34,13 +34,42 @@ cta_text=$(yq -r '.vars.cta.text // ""' "$SITE_YAML") cta_href=$(yq -r '.vars.cta.href // "#"' "$SITE_YAML") year=$(date +%Y) +# i18n: helper to generate data-de/data-en attribute string +i18n_attrs() { + local de="$1" en="$2" + if [ -n "$en" ] && [ "$en" != "null" ]; then + de=$(echo "$de" | sed 's/"/\"/g') + en=$(echo "$en" | sed 's/"/\"/g') + echo " data-de=\"${de}\" data-en=\"${en}\"" + fi +} + +# i18n: read English overrides +title_en=$(yq -r '.title_en // ""' "$SITE_YAML") +description_en=$(yq -r '.description_en // ""' "$SITE_YAML") +role_en=$(yq -r '.vars.role_en // ""' "$SITE_YAML") +tagline_en=$(yq -r '.vars.tagline_en // ""' "$SITE_YAML") +cta_text_en=$(yq -r '.vars.cta.text_en // ""' "$SITE_YAML") + +# i18n: build attribute strings for simple fields +title_i18n=$(i18n_attrs "$title" "$title_en") +description_i18n=$(i18n_attrs "$description" "$description_en") +role_i18n=$(i18n_attrs "$role" "$role_en") +tagline_i18n=$(i18n_attrs "$tagline" "$tagline_en") +cta_i18n=$(i18n_attrs "$cta_text" "$cta_text_en") + # Build tags HTML tags_html="" tag_count=$(yq -r '.vars.tags | length' "$SITE_YAML" 2>/dev/null || echo "0") if [ "$tag_count" -gt 0 ]; then for i in $(seq 0 $((tag_count - 1))); do tag=$(yq -r ".vars.tags[$i]" "$SITE_YAML") - tags_html="${tags_html} ${tag}\n" + tag_en=$(yq -r ".vars.tags_en[$i] // \"\"" "$SITE_YAML" 2>/dev/null || echo "") + tag_i18n="" + if [ -n "$tag_en" ] && [ "$tag_en" != "null" ]; then + tag_i18n="$(i18n_attrs "$tag" "$tag_en")" + fi + tags_html="${tags_html} ${tag}\n" done fi @@ -53,17 +82,25 @@ if [ "$section_count" -gt 0 ]; then sec_title=$(yq -r ".vars.sections[$i].title // \"\"" "$SITE_YAML") if [ "$sec_type" = "features" ]; then + sec_title_en=$(yq -r ".vars.sections[$i].title_en // \"\"" "$SITE_YAML") sections_html="${sections_html}
${item_desc}
\n" + sections_html="${sections_html}${item_desc}
\n" sections_html="${sections_html}${bio}
\n" + if [ -n "$sec_title" ]; then + sec_title_i18n=$(i18n_attrs "$sec_title" "$sec_title_en") + sections_html="${sections_html}${bio}
\n" sections_html="${sections_html}/g' | sed '1s/^/
/' | sed '$s/$/<\/p>/') + content_en=$(yq -r '.vars.content_en // ""' "$SITE_YAML") + if [ -n "$content_en" ] && [ "$content_en" != "null" ]; then + content_html_en=$(echo "$content_en" | sed 's/^$/<\/p>
/g' | sed '1s/^/
/' | sed '$s/$/<\/p>/') + content_i18n=$(i18n_attrs "$content_html" "$content_html_en") + fi fi # Read template file and extract CSS/body sections @@ -184,7 +233,13 @@ BEGIN { -e "s|{{cta_text}}|${cta_text}|g" \ -e "s|{{cta_href}}|${cta_href}|g" \ -e "s|{{year}}|${year}|g" \ - -e "s|{{domain}}|${domain}|g" | \ + -e "s|{{domain}}|${domain}|g" \ + -e "s|{{title_i18n}}|$(echo "$title_i18n" | sed 's/[&/\]/\\&/g')|g" \ + -e "s|{{description_i18n}}|$(echo "$description_i18n" | sed 's/[&/\]/\\&/g')|g" \ + -e "s|{{role_i18n}}|$(echo "$role_i18n" | sed 's/[&/\]/\\&/g')|g" \ + -e "s|{{tagline_i18n}}|$(echo "$tagline_i18n" | sed 's/[&/\]/\\&/g')|g" \ + -e "s|{{cta_i18n}}|$(echo "$cta_i18n" | sed 's/[&/\]/\\&/g')|g" \ + -e "s|{{content_i18n}}|$(echo "$content_i18n" | sed 's/[&/\]/\\&/g')|g" | \ sed "s|{{tags_html}}|$(printf '%b' "$tags_html" | sed 's/[&/\]/\\&/g; s/$/\\/' | sed '$ s/\\$//')|g" | \ sed "s|{{sections_html}}|$(printf '%b' "$sections_html" | sed 's/[&/\]/\\&/g; s/$/\\/' | sed '$ s/\\$//')|g" | \ sed "s|{{content_html}}|$(printf '%b' "$content_html" | sed 's/[&/\]/\\&/g; s/$/\\/' | sed '$ s/\\$//')|g" diff --git a/sites/ichbinotto.de/index.html b/sites/ichbinotto.de/index.html index 1640f16..d6d84e6 100644 --- a/sites/ichbinotto.de/index.html +++ b/sites/ichbinotto.de/index.html @@ -435,7 +435,8 @@
Otto — mai-otto.de — ein Projekt von msbls.de
- + +