Allow substitutions in translated strings
This commit is contained in:
parent
87d760e4a2
commit
43fc46a9fc
@ -164,8 +164,7 @@ select {
|
||||
padding-right: 20px;
|
||||
}
|
||||
#pfooter {
|
||||
clear: both;
|
||||
font-size: smaller;
|
||||
font-size: .6rem;
|
||||
padding-top: 20px;
|
||||
}
|
||||
#bottom {
|
||||
|
19
js/main.js
19
js/main.js
@ -190,6 +190,7 @@ function getPopupHtml(p, i, count) {
|
||||
'<img class="icon" alt="' + lang['tdistance'] + '" title="' + lang['tdistance'] + '" src="images/distance_blue.svg"> ' +
|
||||
(p.totalMeters.toKm() * factor_km).toFixed(2) + ' ' + unit_km + '<br>' + '</div>';
|
||||
}
|
||||
olHack = (mapapi == 'openlayers') ? ' style="padding-bottom: 2rem"' : '';
|
||||
popup =
|
||||
'<div id="popup">' +
|
||||
'<div id="pheader">' +
|
||||
@ -209,8 +210,8 @@ function getPopupHtml(p, i, count) {
|
||||
(p.accuracy * factor_m).toFixed() + ' ' + unit_m + provider + '<br>' : '') +
|
||||
'</div>' +
|
||||
stats +
|
||||
'<div id="pfooter">' + lang['point'] + ' ' + (i + 1) + ' ' + lang['of'] + ' ' + count + '</div>' +
|
||||
'</div></div>';
|
||||
'</div><div id="pfooter"' + olHack + '>' + sprintf(lang['pointof'], i + 1, count) + '</div>' +
|
||||
'</div>';
|
||||
return popup;
|
||||
}
|
||||
|
||||
@ -364,6 +365,7 @@ function setTime() {
|
||||
// dynamic change of map api
|
||||
var savedBounds;
|
||||
function loadMapAPI(api) {
|
||||
mapapi = api;
|
||||
savedBounds = getBounds();
|
||||
document.getElementById("map-canvas").innerHTML = '';
|
||||
var url = new Array();
|
||||
@ -484,4 +486,15 @@ function removeOnClick(event) {
|
||||
if (!parent.classList.contains('dropdown')) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// naive approach, only %s, %d supported
|
||||
function sprintf() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var format = args.shift();
|
||||
var i = 0;
|
||||
return format.replace(/%%|%s|%d/g, function(match) {
|
||||
if (match == '%%') { return '%'; }
|
||||
return (typeof args[i] != 'undefined') ? args[i++] : match;
|
||||
});
|
||||
};
|
@ -35,8 +35,7 @@ $lang["altitude"] = "Höhe";
|
||||
$lang["ttime"] = "Gesamte Zeit";
|
||||
$lang["aspeed"] = "Durchschnittstempo";
|
||||
$lang["tdistance"] = "Gesamt Entfernung";
|
||||
$lang["point"] = "Punkt"; //Punkt x von y
|
||||
$lang["of"] = "von";
|
||||
$lang["pointof"] = "Punkt %d von %d";
|
||||
$lang["summary"] = "Streckenzusammenfassung";
|
||||
$lang["suser"] = "Wähle Benutzer";
|
||||
$lang["logout"] = "Abmelden";
|
||||
|
@ -37,8 +37,7 @@ $lang["altitude"] = "Altitude";
|
||||
$lang["ttime"] = "Total time";
|
||||
$lang["aspeed"] = "Average speed";
|
||||
$lang["tdistance"] = "Total distance";
|
||||
$lang["point"] = "Point"; //Point x of y
|
||||
$lang["of"] = "of";
|
||||
$lang["pointof"] = "Point %d of %d"; // e.g. Point 3 of 10
|
||||
$lang["summary"] = "Trip summary";
|
||||
$lang["suser"] = "select user";
|
||||
$lang["logout"] = "Log out";
|
||||
|
@ -35,8 +35,7 @@ $lang["altitude"] = "Altitud";
|
||||
$lang["ttime"] = "Tiempo total";
|
||||
$lang["aspeed"] = "Velocidad media";
|
||||
$lang["tdistance"] = "Distancia total";
|
||||
$lang["point"] = "Punto"; //Point x of y
|
||||
$lang["of"] = "de";
|
||||
$lang["pointof"] = "Punto %d de %d";
|
||||
$lang["summary"] = "Resumen del viaje";
|
||||
$lang["suser"] = "seleccione usuario";
|
||||
$lang["logout"] = "Cerrar sesión";
|
||||
|
@ -35,8 +35,7 @@ $lang["altitude"] = "Altitude";
|
||||
$lang["ttime"] = "Temps total";
|
||||
$lang["aspeed"] = "Vitesse moyenne";
|
||||
$lang["tdistance"] = "Dist. totale";
|
||||
$lang["point"] = "Point"; //Point x of y
|
||||
$lang["of"] = "de";
|
||||
$lang["pointof"] = "Point %d de %d";
|
||||
$lang["summary"] = "Résumé du trajet";
|
||||
$lang["suser"] = "Sélectionner un utilisateur";
|
||||
$lang["logout"] = "Déconnexion";
|
||||
|
@ -36,8 +36,7 @@ $lang["ttime"] = "Menetidő";
|
||||
$lang["aspeed"] = "Átlagsebesség";
|
||||
$lang["tdistance"] = "Megtett út";
|
||||
$lang["suser"] = "Felhasználónév";
|
||||
$lang["point"] = "Rögzített pontok száma";
|
||||
$lang["of"] = "/";
|
||||
$lang["pointof"] = "Rögzített pontok száma %d / %d";
|
||||
$lang["summary"] = "Utazás adatai";
|
||||
$lang["logout"] = "Kilépés";
|
||||
$lang["login"] = "Belépés";
|
||||
|
@ -35,8 +35,7 @@ $lang["altitude"] = "Altitudine";
|
||||
$lang["ttime"] = "Tempo totale";
|
||||
$lang["aspeed"] = "Velocità media";
|
||||
$lang["tdistance"] = "Distanza totale";
|
||||
$lang["point"] = "Punto"; //Point x of y
|
||||
$lang["of"] = "di";
|
||||
$lang["point"] = "Punto %d di %d";
|
||||
$lang["summary"] = "Sommario";
|
||||
$lang["suser"] = "scegli utente";
|
||||
$lang["logout"] = "Esci";
|
||||
|
@ -36,8 +36,7 @@ $lang["ttime"] = "Czas podróży";
|
||||
$lang["aspeed"] = "Średnia prędkość";
|
||||
$lang["tdistance"] = "Odległość";
|
||||
$lang["suser"] = "wybierz login";
|
||||
$lang["point"] = "Punkt";
|
||||
$lang["of"] = "z";
|
||||
$lang["pointof"] = "Punkt %d z %d";
|
||||
$lang["summary"] = "Podsumowanie";
|
||||
$lang["logout"] = "Wyloguj";
|
||||
$lang["login"] = "Zaloguj";
|
||||
|
@ -29,9 +29,9 @@ require_once(ROOT_DIR . "/helpers/position.php");
|
||||
*/
|
||||
function addStyle($xml, $name, $url) {
|
||||
$xml->startElement("Style");
|
||||
$xml->writeAttribute("id", $name."Style");
|
||||
$xml->writeAttribute("id", "{$name}Style");
|
||||
$xml->startElement("IconStyle");
|
||||
$xml->writeAttribute("id", $name."Icon");
|
||||
$xml->writeAttribute("id", "{$name}Icon");
|
||||
$xml->startElement("Icon");
|
||||
$xml->writeElement("href", $url);
|
||||
$xml->endElement();
|
||||
@ -50,7 +50,7 @@ function toHMS($s) {
|
||||
$h = floor(($s % 86400) / 3600);
|
||||
$m = floor((($s % 86400) % 3600) / 60);
|
||||
$s = (($s % 86400) % 3600) % 60;
|
||||
return (($d > 0) ? ($d." d ") : "").(substr("00".$h, -2)).":".(substr("00".$m, -2)).":".(substr("00".$s, -2));
|
||||
return (($d > 0) ? "$d d " : "") . sprintf("%02d:%02d:%02d", $h, $m, $s);
|
||||
}
|
||||
|
||||
$type = isset($_REQUEST["type"]) ? $_REQUEST["type"] : "kml";
|
||||
@ -92,7 +92,7 @@ if ($trackId && $userId) {
|
||||
case "kml":
|
||||
default:
|
||||
header("Content-type: application/vnd.google-earth.kml+xml");
|
||||
header("Content-Disposition: attachment; filename=\"track" . $positionsArr[0]->trackId . ".kml\"");
|
||||
header("Content-Disposition: attachment; filename=\"track{$positionsArr[0]->trackId}.kml\"");
|
||||
$xml = new XMLWriter();
|
||||
$xml->openURI("php://output");
|
||||
$xml->setIndent(true);
|
||||
@ -128,26 +128,26 @@ if ($trackId && $userId) {
|
||||
|
||||
if(++$i == count($positionsArr)) { $style = "#greenStyle"; } // last element
|
||||
$xml->startElement("Placemark");
|
||||
$xml->writeAttribute("id", "point_" . $position->id);
|
||||
$xml->writeAttribute("id", "point_{$position->id}");
|
||||
$description =
|
||||
"<div style=\"font-weight: bolder;padding-bottom: 10px;border-bottom: 1px solid gray;\">".
|
||||
$lang["user"].": ".strtoupper($position->userLogin)."<br>".$lang["track"].": ".strtoupper($position->trackName).
|
||||
"</div>".
|
||||
"<div>".
|
||||
"<div style=\"padding-top: 10px;\"><b>".$lang["time"].":</b> ".$position->time."<br>".
|
||||
(!is_null($position->speed) ? "<b>".$lang["speed"].":</b> ".round($position->speed * 3.6 * $factor_kmh, 2)." ".$unit_kmh."<br>" : "").
|
||||
(!is_null($position->altitude) ? "<b>".$lang["altitude"].":</b> ".round($position->altitude * $factor_m)." ".$unit_m."<br>" : "").
|
||||
"<b>".$lang["ttime"].":</b> ".toHMS($totalSeconds)."<br>".
|
||||
"<b>".$lang["aspeed"].":</b> ".(($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0)." ".$unit_kmh."<br>".
|
||||
"<b>".$lang["tdistance"].":</b> ".round($totalMeters / 1000 * $factor_km, 2)." ".$unit_km."<br>"."</div>".
|
||||
"<div style=\"font-size: smaller;padding-top: 10px;\">".$lang["point"]." ".$i." ".$lang["of"]." ".count($positionsArr)."</div>".
|
||||
"<div style=\"font-weight: bolder; padding-bottom: 10px; border-bottom: 1px solid gray;\">" .
|
||||
"{$lang["user"]}: {$position->userLogin}<br>{$lang["track"]}: {$position->trackName}" .
|
||||
"</div>" .
|
||||
"<div>" .
|
||||
"<div style=\"padding-top: 10px;\"><b>{$lang["time"]}:</b> {$position->time}<br>" .
|
||||
(!is_null($position->speed) ? "<b>{$lang["speed"]}:</b> " . round($position->speed * 3.6 * $factor_kmh, 2) . " {$unit_kmh}<br>" : "") .
|
||||
(!is_null($position->altitude) ? "<b>{$lang["altitude"]}:</b> " . round($position->altitude * $factor_m) . " {$unit_m}<br>" : "") .
|
||||
"<b>{$lang["ttime"]}:</b> " . toHMS($totalSeconds) . "<br>" .
|
||||
"<b>{$lang["aspeed"]}:</b> " . (($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0) . " {$unit_kmh}<br>" .
|
||||
"<b>{$lang["tdistance"]}:</b> " . round($totalMeters / 1000 * $factor_km, 2) . " " . $unit_km . "<br></div>" .
|
||||
"<div style=\"font-size: smaller; padding-top: 10px;\">" . sprintf($lang["pointof"], $i, count($positionsArr)) . "</div>" .
|
||||
"</div>";
|
||||
$xml->startElement("description");
|
||||
$xml->writeCData($description);
|
||||
$xml->endElement();
|
||||
$xml->writeElement("styleUrl", $style);
|
||||
$xml->startElement("Point");
|
||||
$coordinate[$i] = $position->longitude.",".$position->latitude.(!is_null($position->altitude) ? ",".$position->altitude : "");
|
||||
$coordinate[$i] = "{$position->longitude},{$position->latitude}" . (!is_null($position->altitude) ? ",{$position->altitude}" : "");
|
||||
$xml->writeElement("coordinates", $coordinate[$i]);
|
||||
$xml->endElement();
|
||||
$xml->endElement();
|
||||
@ -206,14 +206,13 @@ if ($trackId && $userId) {
|
||||
$xml->writeElement("name", ++$i);
|
||||
$xml->startElement("desc");
|
||||
$description =
|
||||
$lang["user"].": ".strtoupper($position->userLogin)." ".$lang["track"].": ".strtoupper($position->trackName).
|
||||
" ".$lang["time"].": ".$position->time.
|
||||
(!is_null($position->speed) ? " ".$lang["speed"].": ".round($position->speed * 3.6 * $factor_kmh, 2)." ".$unit_kmh : "").
|
||||
(!is_null($position->altitude) ? " ".$lang["altitude"].": ".round($position->altitude * $factor_m)." ".$unit_m : "").
|
||||
" ".$lang["ttime"].": ".toHMS($totalSeconds)."".
|
||||
" ".$lang["aspeed"].": ".(($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0)." ".$unit_kmh.
|
||||
" ".$lang["tdistance"].": ".round($totalMeters / 1000 * $factor_km, 2)." ".$unit_km.
|
||||
" ".$lang["point"]." ".$i." ".$lang["of"]." ".count($positionsArr);
|
||||
"{$lang["user"]}: {$position->userLogin} {$lang["track"]}: {$position->trackName} {$lang["time"]}: {$position->time}" .
|
||||
(!is_null($position->speed) ? " {$lang["speed"]}: " . round($position->speed * 3.6 * $factor_kmh, 2) . " {$unit_kmh}" : "") .
|
||||
(!is_null($position->altitude) ? " {$lang["altitude"]}: " . round($position->altitude * $factor_m) . " {$unit_m}" : "") .
|
||||
" {$lang["ttime"]}: " . toHMS($totalSeconds) .
|
||||
" {$lang["aspeed"]}: " . (($totalSeconds != 0) ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0) . " {$unit_kmh}" .
|
||||
" {$lang["tdistance"]}: " . round($totalMeters / 1000 * $factor_km, 2) . " {$unit_km}" .
|
||||
" " . sprintf($lang["pointof"], $i, count($positionsArr));
|
||||
$xml->writeCData($description);
|
||||
$xml->endElement();
|
||||
$xml->endElement();
|
||||
|
Loading…
x
Reference in New Issue
Block a user