Skip to content
Snippets Groups Projects
Commit f79d032e authored by Bob Mottram's avatar Bob Mottram
Browse files

Whether to keep local translations

parent cc374ca8
No related branches found
No related tags found
No related merge requests found
......@@ -39,9 +39,11 @@ function web_admin_translations_from_upstream {
# copy over any existing upstream translations
if [ -d "/root/${PROJECT_NAME}/webadmin/translations" ]; then
local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local
# shellcheck disable=SC2086
cp -r /root/${PROJECT_NAME}/webadmin/translations /var/www/${local_hostname}/htdocs/admin/
chown -R www-data:www-data "/var/www/${local_hostname}/htdocs/admin/translations"
if [ ! -f "/var/www/${local_hostname}/htdocs/admin/.keep_translations.txt" ]; then
# shellcheck disable=SC2086
cp -r /root/${PROJECT_NAME}/webadmin/translations /var/www/${local_hostname}/htdocs/admin/
chown -R www-data:www-data "/var/www/${local_hostname}/htdocs/admin/translations"
fi
fi
}
......
......@@ -91,24 +91,6 @@
opacity: 0.7;
}
.chip {
display: inline-block;
padding: 0 25px;
height: 50px;
font-size: 70%;
line-height: 50px;
border-radius: 25px;
background-color: #f1f1f1;
}
.chip img {
float: left;
margin: 0 10px 0 -25px;
height: 50px;
width: 50px;
border-radius: 50%;
}
.translationstring {
text-align: left;
font-size: 70%;
......@@ -120,6 +102,25 @@
.translationtable {
width: 100%;
}
.myCheckbox input {
position: relative;
z-index: -9999;
}
.myCheckbox span {
width: 50%;
}
input[type=checkbox]
{
/* Double-sized Checkboxes */
-ms-transform: scale(2); /* IE */
-moz-transform: scale(2); /* FF */
-webkit-transform: scale(2); /* Safari and Chrome */
-o-transform: scale(2); /* Opera */
padding: 10px;
}
</style>
</head>
<body>
......@@ -134,6 +135,10 @@
<input type="hidden" name="language" value="TRANSLATELANGUAGE">
<input type="submit" name="submittranslationscancel" translate="yes" lang="en" value="Cancel">
<input type="submit" name="submittranslations" translate="yes" lang="en" value="Update">
<br><br>
<label class="myCheckbox">
<input type="checkbox" name="submitkeeptranslations" value="0"><span translate="yes" lang="en">Keep changes</span>
</label>
</center>
<br><br>
......
......@@ -15,6 +15,19 @@ if (isset($_POST['submitlanguage'])) {
if (isset($_POST['submittranslatelanguage'])) {
$language = htmlspecialchars($_POST['language']);
if (file_exists('.keep_translations.txt')) {
exec('sed -i "s|submitkeeptranslations\" value=\"0\"|submitkeeptranslations\" value=\"1\"|g" translations_template.html');
if (file_exists('translations.html')) {
exec('sed -i "s|submitkeeptranslations\" value=\"0\"|submitkeeptranslations\" value=\"1\"|g" translations.html');
}
}
else {
exec('sed -i "s|submitkeeptranslations\" value=\"0\"|submitkeeptranslations\" value=\"0\"|g" translations_template.html');
if (file_exists('translations.html')) {
exec('sed -i "s|submitkeeptranslations\" value=\"0\"|submitkeeptranslations\" value=\"0\"|g" translations.html');
}
}
if (!file_exists("translations")) {
mkdir("translations");
}
......
......@@ -4,6 +4,22 @@
$output_filename = "language.html";
if (isset($_POST['submitkeeptranslations'])) {
$keep = $_POST['submitkeeptranslations'];
if ($keep === '0') {
if (file_exists('.keep_translations.txt')) {
exec('rm .keep_translations.txt');
}
}
else {
if (!file_exists('.keep_translations.txt')) {
$keep_file = fopen(".keep_translations.txt", "w") or die("Unable to create keep_translations file");
fwrite($keep_file, "1");
fclose($keep_file);
}
}
}
if (isset($_POST['submittranslations'])) {
$language = htmlspecialchars($_POST['language']);
$english = $_POST['english'];
......@@ -16,6 +32,10 @@ if (isset($_POST['submittranslations'])) {
fclose($language_file);
$keep_file = fopen(".keep_translations.txt", "w") or die("Unable to create keep_translations file");
fwrite($keep_file, "1");
fclose($keep_file);
$language_file = fopen(".translations.txt", "w") or die("Unable to create translations file");
fwrite($language_file, $language);
fclose($language_file);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment