This commit is contained in:
manuel
2026-05-22 10:33:58 +03:00
parent 002db90daf
commit ed069e74f1
7 changed files with 186 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
# Maintainer: EndeavourOS-Team <info@endeavouros.com>
pkgname=eos-langs
pkgdesc="Translation support for many apps"
pkgver=25.12
pkgrel=1
arch=('any')
license=('GPL')
depends=(bash)
optdepends=()
url=https://github.com/endeavouros-team/PKGBUILDS/tree/master/$pkgname
_url_dl=https://raw.githubusercontent.com/endeavouros-team/PKGBUILDS/master/$pkgname
source=(
# $_url_dl/etr-get-lang
# $_url_dl/etr-lang-init
$_url_dl/etr-support
$_url_dl/etr_fi_welcome
$_url_dl/etr_en_welcome
)
sha512sums=('0030ff81d89b2f44ed790b2f4d0c652e843d3a84ce8da35833bd282a98fdff98215a932049e37a3f8835a6110b76be4cfb0d1a2b51bb801a94d758f0da5befc0'
'5d731d7702702dfb29a7dd536bf588891d457afd3e0ae4f829b52dc821a02ccf8a2ca4e4e5919a39f382b245a7a629863333cc368cf27b4945870b9448a0f4e4'
'4b85f5e904381d8d83891c68767db26ce200ae59b2a5095c1c21d686f70d6f6a306ac8be616a9268cbdc187c9a573bfefc6f5cc0094398d4400c26245104638d')
package() {
local src filename
for src in "${source[@]}" ; do
filename="${src##*/}"
case "$filename" in
etr-support) install -Dm644 "$filename" "$pkgdir/usr/share/endeavouros/translations/$filename" ;;
etr_*_*) install -Dm644 "$filename" "$pkgdir/usr/share/endeavouros/translations/$filename" ;;
*) install -Dm755 "$filename" "$pkgdir/usr/bin/$filename" ;;
esac
done
}
#########################################################################################################
# cat <<EOF > $headfile
#!/bin/bash
# All translations need the following line:
# source /usr/share/endeavouros/translations/etr-support || exit 1
# The ETR_ARR (associative) array below contains all English translations for this app.
# Each "entry" in ETR_ARR consists of two elements: "key" and "translation-string".
# Technically, the "key" is used as the index to the associative array ETR_ARR.
# Then ETR_ARR[key] becomes a translation-string.
# The key should not include white spaces.
# The translation-string will be used as the format parameter to printf.
# So the translation-string may include one or more %s like placeholders for additional parameters.
#
# When writing a new translation it is easiest to copy the ETR_ARR array entries from
# the English translation file (translations__en) to a new file
# (e.g. translations__de for German translations) and translate every "entry" in ETR_ARR
# below this line.
# declare -A ETR_ARR=(
# EOF
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
case "$LANG" in
nl_NL* | pt_BR* | uk_UA* | zh_CN* | zh_HK* | zh_SG* | zh_TW*)
echo ${LANG::4} ;;
*)
echo ${LANG::2} ;;
esac
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
DIE() { echo "$progname: error: $1" >&2; exit 1; }
Main()
{
local progname=${0##*/}
local appname="$1"
local lang="$2" # optional
[ "$appname" ] || DIE "appname missing"
[ "$lang" ] || lang=$(eos-get-lang)
source "/usr/share/endeavouros/translations/translation-${lang}-${appname}" || DIE "initialization failed"
}
Main "$@"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
ETR() {
local key="$1"
shift
printf "${ETR_ARR[$key]}" "$@"
}
_etr_get_lang_() {
case "$LANG" in
nl_NL* | pt_BR* | uk_UA* | zh_CN* | zh_HK* | zh_SG* | zh_TW*)
echo ${LANG::4} ;;
*)
echo ${LANG::2} ;;
esac
}
source /usr/share/endeavouros/translations/etr_$(_etr_get_lang_)_"$1" || exit 1
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# English translations for app welcome-test.
#
# Syntax for the entries in ETR_ARR:
# key "translation"
# where
# key Identifies the translation item.
# "translation" The translation string for the particular key.
# Use %s as the placeholder for parameters.
# Example:
# declare -A ETR_ARR=(
# cal_info2 "<b>Offline</b> method gives you the %s desktop.\nInternet connection is not needed.\n\n"
# _commonphrase_not_found "%s not found"
# )
declare -A ETR_ARR=(
cal_info2 "<b>Offline</b> method gives you the %s desktop.\nInternet connection is not needed.\n\n"
_commonphrase_not_found "%s not found"
)
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# Finnish translations for app welcome-test.
#
# Syntax for the entries in ETR_ARR:
# key "translation"
# where
# key Identifies the translation item.
# "translation" The translation string for the particular key.
# Use %s as the placeholder for parameters.
# Example:
# declare -A ETR_ARR=(
# cal_info2 "<b>Offline</b> method gives you the %s desktop.\nInternet connection is not needed.\n\n"
# _commonphrase_not_found "%s not found"
# )
declare -A ETR_ARR=(
cal_info2 "<b>Offline</b> asentaa %s-työpöydän.\nInternet-yhteyttä ei tarvita.\n\n"
_commonphrase_not_found "%s ei saatavilla"
)
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
MyApp2() {
local DE=Xfce
local file=file.txt
echo "$(ETR cal_info2 $DE)"
echo "$(ETR _commonphrase_not_found "$file")"
}
Main() {
source /usr/share/endeavouros/translations/etr-support welcome || exit 1
MyApp2 "$@"
}
Main "$@"
#####################################################################
# MyApp1() {
# local key2 val out
# for key2 in "${!ETR_ARR[@]}" ; do
# val=${ETR_ARR[$key2]}
# #echo -e "key2 = '$key2'\tval = '$val'"
# #printf -v out "%s:\t$val\n" "$key2" "$XDG_CURRENT_DESKTOP"
# printf -v out "%s:\t%s\n" "$key2" "$val"
# printf "$out" "$XDG_CURRENT_DESKTOP"
# done
# echo ""
# key2=hello_world
# printf "%s:\t${ETR_ARR[$key2]}\n" "$key2" "$USER"
# printf "%s:\t$(ltr "$key2")\n" "$key2" $USER
# key2=whats_up2
# printf "%s:\t$(ltr "$key2")\n" "$key2" "$USER"
# key2=""
# }