Skip to content

Commit

Permalink
Wall: geotag translation
Browse files Browse the repository at this point in the history
  • Loading branch information
veselcraft committed Aug 3, 2023
1 parent a5f1433 commit 0262da5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Web/Presenters/WallPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ function renderMakePost(int $wall): void
if (!is_null($this->postParam("geo")) && $this->postParam("geo") != "none") {
$geo = json_decode($this->postParam("geo"), true, JSON_UNESCAPED_UNICODE);
if (!$geo["lat"] || !$geo["lng"] || !$geo["name"]) {
$this->flashFail("err", tr("error"), "Ошибка при прикреплении геометки");
$this->flashFail("err", tr("error"), tr("error_geolocation"));
}
}

Expand Down Expand Up @@ -508,7 +508,7 @@ function renderNearest(int $wall, int $post_id): void
$lon = $post->getLon();

if (!$lat || !$lon)
$this->returnJson(["success" => false, "error" => "У поста не указана гео-метка"]);
$this->returnJson(["success" => false, "error" => tr("error_no_geotag")]);

$query = file_get_contents(__DIR__ . "/../Models/sql/get-nearest-posts.tsql");
$_posts = DatabaseConnection::i()->getContext()->query($query, $lat, $lon, $post->getId())->fetchAll();
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/templates/components/post/microblogpost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</div>
<div n:if="$post->getGeo()" style="padding: 4px;">
<div style="border-bottom: #ECECEC solid 1px;" />
<div style="cursor: pointer; padding: 4px;" onclick="javascript:openGeo({$post->getGeo()}, {$post->getOwner()->getId()}, {$post->getVirtualId()})"><b>Геометка</b>: {$post->getGeo()->name}</div>
<div style="cursor: pointer; padding: 4px;" onclick="javascript:openGeo({$post->getGeo()}, {$post->getOwner()->getId()}, {$post->getVirtualId()})"><b>{_geotag}</b>: {$post->getGeo()->name}</div>
</div>
<div n:if="$post->isAd()" style="color:grey;">
<br/>
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/templates/components/post/oldpost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</div>
<div n:if="$post->getGeo()" style="padding: 4px;">
<div style="border-bottom: #ECECEC solid 1px;" />
<div style="cursor: pointer; padding: 4px;" onclick="javascript:openGeo({$post->getGeo()}, {$post->getOwner()->getId()}, {$post->getVirtualId()})"><b>Геометка</b>: {$post->getGeo()->name}</div>
<div style="cursor: pointer; padding: 4px;" onclick="javascript:openGeo({$post->getGeo()}, {$post->getOwner()->getId()}, {$post->getVirtualId()})"><b>{_geotag}</b>: {$post->getGeo()->name}</div>
</div>
<div n:if="$post->isAd()" style="color:grey;">
<br/>
Expand Down
14 changes: 7 additions & 7 deletions Web/static/js/al_wall.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ async function showArticle(note_id) {
}

async function initGeo(tid) {
MessageBox("Прикрепить геометку", "<div id=\"osm-map\"></div>", ["Прикрепить", "Отмена"], [(function () {
MessageBox(tr("attach_geotag"), "<div id=\"osm-map\"></div>", ["Прикрепить", tr("cancel")], [(function () {
let marker = {
lat: currentMarker._latlng.lat,
lng: currentMarker._latlng.lng,
name: currentMarker._popup._content
};
$(`#post-buttons${tid} #geo`).val(JSON.stringify(marker));
$(`#post-buttons${tid} .post-has-geo`).text(`Геометка: ${marker.name}`);
$(`#post-buttons${tid} .post-has-geo`).text(`${tr("geotag")}: ${marker.name}`);
$(`#post-buttons${tid} .post-has-geo`).show();
}), Function.noop]);

Expand Down Expand Up @@ -323,8 +323,8 @@ async function initGeo(tid) {
currentMarker = L.marker([lat, lng]).addTo(map);
currentMarker.bindPopup(name).openPopup();

console.log("Широта: " + lat + ", Долгота: " + lng);
console.log("Название места: " + name);
console.log(`${tr("latitude")}: ${lat}, ${tr("longitude")}: ${lng}`);
console.log(`${tr("name_of_the_place")}: ${name}`);

let marker = {
lat: lat,
Expand All @@ -343,7 +343,7 @@ async function initGeo(tid) {
}

function openGeo(data, owner_id, virtual_id) {
MessageBox("Геометка", "<div id=\"osm-map\"></div>", ["Ближайшие посты", "OK"], [(function () {
MessageBox(tr("geotag"), "<div id=\"osm-map\"></div>", [tr("nearest_posts"), "OK"], [(function () {
getNearPosts(owner_id, virtual_id);
}), Function.noop]);

Expand Down Expand Up @@ -372,7 +372,7 @@ function getNearPosts(owner_id, virtual_id) {
if (response.success) {
openNearPosts(response);
} else {
MessageBox("Ошибка", "Произошла ошибка в ходе запроса:" + (response?.error ?? "Неизвестная ошибка"), ["OK"], [Function.noop]);
MessageBox(tr("error"), `${tr("error_segmentation")}: ${(response?.error ?? "Unknown error")}`, ["OK"], [Function.noop]);
}
}
});
Expand Down Expand Up @@ -408,7 +408,7 @@ function openNearPosts(posts) {
</div>
<div style="padding: 4px;">
<div style="border-bottom: #ECECEC solid 1px;"></div>
<div style="cursor: pointer; padding: 4px;"><b>Геометка</b>: ${post.geo.name}</div>
<div style="cursor: pointer; padding: 4px;"><b>${tr("geotag")}</b>: ${post.geo.name}</div>
</div>
</div>
</td>
Expand Down
8 changes: 8 additions & 0 deletions locales/en.strings
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"attach" = "Attach";
"attach_photo" = "Attach photo";
"attach_video" = "Attach video";
"attach_geotag" = "Attach geotag";
"draw_graffiti" = "Draw graffiti";
"no_posts_abstract" = "Nobody wrote anything here... So far.";
"attach_no_longer_available" = "This attachment is no longer available.";
Expand All @@ -213,6 +214,11 @@
"graffiti" = "Graffiti";

"reply" = "Reply";
"geotag" = "Geotag";
"nearest_posts" = "Nearest posts";
"Latitude" = "Latitude";
"longitude" = "Longitude";
"name_of_the_place" = "Name of the place";

/* Friends */

Expand Down Expand Up @@ -1100,6 +1106,8 @@
"media_file_corrupted_or_too_large" = "The media content file is corrupted or too large.";
"post_is_empty_or_too_big" = "The post is empty or too big.";
"post_is_too_big" = "The post is too big.";
"error_geolocation" = "Error while trying to pin geolocation";
"error_no_geotag" = "There is no geo-tag pinned in this post";

/* Admin actions */

Expand Down
8 changes: 8 additions & 0 deletions locales/ru.strings
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,19 @@
"attach" = "Прикрепить";
"attach_photo" = "Прикрепить фото";
"attach_video" = "Прикрепить видео";
"attach_geotag" = "Прикрепить геометку";
"draw_graffiti" = "Нарисовать граффити";
"no_posts_abstract" = "Здесь никто ничего не написал... Пока.";
"attach_no_longer_available" = "Это вложение больше недоступно.";
"open_post" = "Открыть запись";
"version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK.";
"graffiti" = "Граффити";
"reply" = "Ответить";
"geotag" = "Геоточка";
"nearest_posts" = "Ближайшие посты";
"Latitude" = "Широта";
"longitude" = "Долгота";
"name_of_the_place" = "Название места";

/* Friends */

Expand Down Expand Up @@ -1000,6 +1006,8 @@
"media_file_corrupted_or_too_large" = "Файл медиаконтента повреждён или слишком велик.";
"post_is_empty_or_too_big" = "Пост пустой или слишком большой.";
"post_is_too_big" = "Пост слишком большой.";
"error_geolocation" = "Ошибка при прикреплении геометки";
"error_no_geotag" = "У поста не указана гео-метка";

/* Admin actions */

Expand Down

0 comments on commit 0262da5

Please sign in to comment.