Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
d891e46d
Commit
d891e46d
authored
6 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Do translations
parent
d8be0582
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/freedombone-installer
+36
-1
36 additions, 1 deletion
src/freedombone-installer
src/freedombone-utils-webadmin
+30
-0
30 additions, 0 deletions
src/freedombone-utils-webadmin
with
66 additions
and
1 deletion
src/freedombone-installer
+
36
−
1
View file @
d891e46d
...
...
@@ -132,6 +132,34 @@ ICECAST_DIR=/icestream
ICECAST_JINGLES
=
/jingles
liquidsoap_script
=
/etc/liquidsoapuser/radio.liq
function
web_admin_translate
{
if
!
grep
-q
'DEFAULT_LANGUAGE='
"
$CONFIGURATION_FILE
"
;
then
return
fi
language
=
$(
grep
'DEFAULT_LANGUAGE='
"
$CONFIGURATION_FILE
"
|
head
-n
1 |
awk
-F
'='
'{print $2}'
)
if
[
!
"
$language
"
]
;
then
return
fi
local_hostname
=
$(
grep
'host-name'
/etc/avahi/avahi-daemon.conf |
awk
-F
'='
'{print $2}'
)
.local
webadmin_install_dir
=
"/var/www/
${
local_hostname
}
/htdocs/admin"
translations_file
=
"/var/www/
${
local_hostname
}
/htdocs/admin/translations/
${
language
}
.txt"
if
[
!
-f
"
$translations_file
"
]
;
then
return
fi
while
read
-r
trans
;
do
translated_text
=
$(
echo
"
$trans
"
|
awk
-F
'|'
'{print $2}'
)
if
[
"
$translated_text
"
]
;
then
english_text
=
$(
echo
"
$trans
"
|
awk
-F
'|'
'{print $1}'
)
for
webfile
in
"/var/www/
${
local_hostname
}
/htdocs/admin"
/
*
.html
;
do
sed
-i
"/translate=
\"
yes
\"
/s|>
$english_text
<|>
$translated_text
<|g"
"
$webfile
"
;
done
fi
done
<
"
$translations_file
"
}
function
backup_mount_drive
{
backup_drive_mounted
=
if
[
"
$1
"
]
;
then
...
...
@@ -674,6 +702,8 @@ function web_admin_setup_login {
echo
-n
"
$webadmin_password
"
>
${
IMAGE_PASSWORD_FILE
}
fi
web_admin_translate
echo
-n
"
$INSTALL_STATE_WEBADMIN_PASSWORD_CTEATED
"
>
"
$install_state_file
"
install_state
=
$INSTALL_STATE_WEBADMIN_PASSWORD_CTEATED
}
...
...
@@ -2273,9 +2303,14 @@ function change_language {
webadmin_update_version
fi
sed
-i
"s|DEFAULT_LANGUAGE=.*|DEFAULT_LANGUAGE=
$language
|g"
"
$CONFIGURATION_FILE
"
if
[
-f
"
$webadmin_install_dir
/translations/
${
language
}
.txt"
]
;
then
web_admin_translate
fi
chown
-R
www-data:www-data
"
$webadmin_install_dir
/*"
sed
-i
"s|DEFAULT_LANGUAGE=.*|DEFAULT_LANGUAGE=
$language
|g"
"
$CONFIGURATION_FILE
"
locale-gen
"
${
language
}
"
update-locale
LANG
=
"
${
language
}
"
update-locale
LANGUAGE
=
"
${
language
}
"
...
...
This diff is collapsed.
Click to expand it.
src/freedombone-utils-webadmin
+
30
−
0
View file @
d891e46d
...
...
@@ -35,6 +35,34 @@ WEBADMIN_LOGIN_TEXT=$"Welcome to ${PROJECT_NAME}"
WEBADMIN_ONION_PORT=5783
function web_admin_translate {
if ! grep -q 'DEFAULT_LANGUAGE=' "$CONFIGURATION_FILE"; then
return
fi
language=$(grep 'DEFAULT_LANGUAGE=' "$CONFIGURATION_FILE" | head -n 1 | awk -F '=' '{print $2}')
if [ ! "$language" ]; then
return
fi
local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local
webadmin_install_dir="/var/www/${local_hostname}/htdocs/admin"
translations_file="/var/www/${local_hostname}/htdocs/admin/translations/${language}.txt"
if [ ! -f "$translations_file" ]; then
return
fi
while read -r trans; do
translated_text=$(echo "$trans" | awk -F '|' '{print $2}')
if [ "$translated_text" ]; then
english_text=$(echo "$trans" | awk -F '|' '{print $1}')
for webfile in "/var/www/${local_hostname}/htdocs/admin"/*.html; do
sed -i "/translate=\"yes\"/s|>$english_text
<
|
>
$translated_text
<
|
g
"
"$
webfile
";
done
fi
done
<"$
translations_file
"
}
function
web_admin_get_hostname
{
#
shellcheck
disable=
SC2154
if
[
!
"$
rootdir
"
];
then
...
...
@@ -1297,6 +1325,8 @@ function install_web_admin {
myqr "http://${WEBADMIN_ONION_HOSTNAME}/admin" -p /root/freedombone/img/onion.png -c -v 8 -n "$webadmin_qrcode"
fi
fi
web_admin_translate
}
# NOTE: deliberately no exit 0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment