blob: 26c16181b9852e621fe9b0a02bef02b58d3431aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/bin/sh
set -e
TESTDIR="$(readlink -f "$(dirname "$0")")"
. "${TESTDIR}/framework"
setupenvironment
ARCH='amd64'
DIST='unstable'
PKG_NAME='foo'
PKG_VERSION='1.0'
SHORT_DESCRIPTION_EN='have you fooed today?'
LONG_DESCRIPTION_EN="${SHORT_DESCRIPTION_EN}
Where there's foo, there's fire."
SHORT_DESCRIPTION_ZZ='bar alter ego'
LONG_DESCRIPTION_ZZ="${SHORT_DESCRIPTION_ZZ}
He who foos last foos best."
configure_languages()
{
{
echo '#clear Acquire::Languages;'
echo 'Acquire::Languages {'
for language in "$@"
do
echo " \"${language}\";"
done
echo '};'
} > rootdir/etc/apt/apt.conf.d/languages.conf
}
new_translation_record()
{
echo "Package: ${1:?Package name expected}"
echo "Description-md5: ${2:?Description-md5 expected}"
echo "Description-${3:?Language code expected}: ${4:?Package description expected}"
echo
}
str_md5sum()
{
echo -n "${1:?String expected}" | md5sum | cut -d ' ' -f 1
}
configarchitecture "${ARCH}"
insertpackage "${DIST}" "${PKG_NAME}" "${ARCH}" "${PKG_VERSION}" '' '' "${LONG_DESCRIPTION_EN}"
# English translation was already added by insertpackage above
new_translation_record "${PKG_NAME}" "$(str_md5sum "${LONG_DESCRIPTION_EN}")" 'zz' "${LONG_DESCRIPTION_ZZ}" > "aptarchive/dists/${DIST}/main/i18n/Translation-zz"
configure_languages en zz
setupaptarchive
# ===========================
#
# Tests
#
# ===========================
# ---- LP: #1907850 - check that we actually include the translations we have in the cache, even if config changed ---
configure_languages en zz
testsuccess aptcache showpkg ${PKG_NAME}
cp rootdir/tmp/testsuccess.output showpkg.output
testsuccess grep -qE Translation-zz showpkg.output
rm rootdir/etc/apt/apt.conf.d/languages.conf
rm rootdir/var/cache/apt/*.bin
testsuccess aptcache showpkg ${PKG_NAME}
cp rootdir/tmp/testsuccess.output showpkg.output
testsuccess grep -qE Translation-zz showpkg.output
# ----------[ apt ]----------
# Test that all translations are searched, but the short
# description is in the first configured language
configure_languages en zz
testequal "${PKG_NAME}/${DIST} ${PKG_VERSION} ${ARCH}
${SHORT_DESCRIPTION_EN}
" apt -qq search alter ego
configure_languages zz en
testequal "${PKG_NAME}/${DIST} ${PKG_VERSION} ${ARCH}
${SHORT_DESCRIPTION_ZZ}
" apt -qq search you today
# Search in configured languages only
configure_languages zz
testempty apt -qq search where fire
# Patterns are AND-ed i.e. all must match against a single
# description translation
configure_languages en zz
testempty apt -qq search there best
# -------[ apt-cache ]-------
# Test that all translations are searched, but the short
# description is in the first configured language
configure_languages en zz
testequal "${PKG_NAME} - ${SHORT_DESCRIPTION_EN}" aptcache search alter ego
configure_languages zz en
testequal "${PKG_NAME} - ${SHORT_DESCRIPTION_ZZ}" aptcache search you today
# Search in configured languages only
configure_languages zz
testempty aptcache search where fire
# Patterns are AND-ed i.e. all must match against a single
# description translation
configure_languages en zz
testempty aptcache search there best
|