From 99d1318ec02694fc520a0dc38ae38565db7e8c3c Mon Sep 17 00:00:00 2001 From: Pascal Abresch Date: Fri, 30 Dec 2022 15:48:34 +0100 Subject: [PATCH] Fix userguide localization Change-Id: Ie52a545b4e50ef3d87c7bfb26e54772fd7816377 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5974 Reviewed-by: nephele Reviewed-by: Niels Sascha Reedijk --- data/bin/welcome | 14 ++++++++++---- src/data/bin/quicktour | 21 +++++++++++++-------- src/data/bin/userguide | 11 +++++++++-- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/data/bin/welcome b/data/bin/welcome index a2b0dc957a..1454766f44 100755 --- a/data/bin/welcome +++ b/data/bin/welcome @@ -1,13 +1,19 @@ #!/bin/sh +language=$(locale -l) +# The locale can be a single 2 char language or in severall segments like en, se_SE or sr_Latn_ME +# this tries to get the 2 char language code from longer locales as a fallback +languageBase=$(echo $language | awk -F_ '{print $1}') welcomeURL="\ https://www.haiku-os.org/docs/welcome/welcome_en.html" -welcomeDir=/boot/system/documentation/welcome/ -welcomeFile=$welcomeDir/welcome_en.html -localizedWelcomeFile=$welcomeDir/welcome_"$LANG".html +welcomeFile=/boot/system/documentation/welcome/welcome_en.html +localizedWelcomeFile=/boot/system/documentation/welcome/welcome_"$language".html +localizedWelcomeFileBase=/boot/system/documentation/welcome/welcome_"$languageBase".html if [ -f $localizedWelcomeFile ]; then - open file://$localizedWelcomeFile + open file:$localizedWelcomeFile +elif [ -f $localizedWelcomeFileBase ]; then + open file:$localizedWelcomeFileBase elif [ -f $welcomeFile ]; then open $welcomeFile else diff --git a/src/data/bin/quicktour b/src/data/bin/quicktour index 596be06184..074f6d1cab 100755 --- a/src/data/bin/quicktour +++ b/src/data/bin/quicktour @@ -1,16 +1,21 @@ #!/bin/sh +language=$(locale -l) +# The locale can be a single 2 char language or in severall segments like en, se_SE or sr_Latn_ME +# this tries to get the 2 char language code from longer locales as a fallback +languageBase=$(echo $language | awk -F_ '{print $1}') quicktourURL="\ https://www.haiku-os.org/docs/welcome/en/quicktour.html" -quicktourDir=/boot/system/documentation/welcome/en/ -quicktourFile=$quicktourDir/quicktour.html -localizedQuicktourDir=/boot/system/documentation/welcome/"$LANG"/ -localizedQuicktourFile=$localizedQuicktourDir/quicktour.html +quicktour=/boot/system/documentation/welcome/en/quicktour.html +localizedQuicktour=/boot/system/documentation/welcome/"$language"/quicktour.html +localizedQuicktourBase=/boot/system/documentation/welcome/"$languageBase"/quicktour.html -if [ -f $localizedQuicktourFile ]; then - open file://$localizedQuicktourFile -elif [ -f $quicktourFile ]; then - open $quicktourFile +if [ -f $localizedQuicktour ]; then + open file:$localizedQuicktour +elif [ -f $localizedQuicktourBase ]; + open file:$localizedQuicktourBase +elif [ -f $quicktour ]; then + open $quicktour else open $quicktourURL fi diff --git a/src/data/bin/userguide b/src/data/bin/userguide index f92e4d1f39..763f27d8a1 100755 --- a/src/data/bin/userguide +++ b/src/data/bin/userguide @@ -1,13 +1,20 @@ #!/bin/bash +language=$(locale -l) +# The locale can be a single 2 char language or in severall segments like en, se_SE or sr_Latn_ME +# this tries to get the 2 char language code from longer locales as a fallback +languageBase=$(echo $language | awk -F_ '{print $1}') userGuideURL="\ https://www.haiku-os.org/docs/userguide/en/contents.html" userGuideDir=/boot/system/documentation/userguide/ userGuide=$userGuideDir/en/contents.html -localizedUserGuide=$userGuideDir/"$LANG"/contents.html +localizedUserGuide=$userGuideDir/"$language"/contents.html +localizedUserGuideBase=$userGuideDir/"$languageBase"/contents.html if [ -f $localizedUserGuide ]; then - open file://$localizedUserGuide + open file:$localizedUserGuide +elif [ -f $localizedUserGuideBase ]; then + open file:$localizedUserGuideBase elif [ -f $userGuide ]; then open $userGuide else