From 0262da5a81f2d8a9b3707cac079e602b7d485cb8 Mon Sep 17 00:00:00 2001 From: veselcraft Date: Thu, 3 Aug 2023 23:48:03 +0300 Subject: [PATCH] Wall: geotag translation --- Web/Presenters/WallPresenter.php | 4 ++-- .../templates/components/post/microblogpost.xml | 2 +- .../templates/components/post/oldpost.xml | 2 +- Web/static/js/al_wall.js | 14 +++++++------- locales/en.strings | 8 ++++++++ locales/ru.strings | 8 ++++++++ 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 8ee663fe..28badd08 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -298,7 +298,7 @@ final class WallPresenter extends OpenVKPresenter 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")); } } @@ -508,7 +508,7 @@ final class WallPresenter extends OpenVKPresenter $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(); diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index a60f3b37..9cd5dc3a 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -75,7 +75,7 @@
-
Геометка: {$post->getGeo()->name}
+
{_geotag}: {$post->getGeo()->name}

diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 8e756929..590037e8 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -69,7 +69,7 @@
-
Геометка: {$post->getGeo()->name}
+
{_geotag}: {$post->getGeo()->name}

diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 2c1dc611..f28bd997 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -265,14 +265,14 @@ async function showArticle(note_id) { } async function initGeo(tid) { - MessageBox("Прикрепить геометку", "
", ["Прикрепить", "Отмена"], [(function () { + MessageBox(tr("attach_geotag"), "
", ["Прикрепить", 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]); @@ -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, @@ -343,7 +343,7 @@ async function initGeo(tid) { } function openGeo(data, owner_id, virtual_id) { - MessageBox("Геометка", "
", ["Ближайшие посты", "OK"], [(function () { + MessageBox(tr("geotag"), "
", [tr("nearest_posts"), "OK"], [(function () { getNearPosts(owner_id, virtual_id); }), Function.noop]); @@ -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]); } } }); @@ -408,7 +408,7 @@ function openNearPosts(posts) {
-
Геометка: ${post.geo.name}
+
${tr("geotag")}: ${post.geo.name}
diff --git a/locales/en.strings b/locales/en.strings index 4aaa4483..27115458 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -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."; @@ -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 */ @@ -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 */ diff --git a/locales/ru.strings b/locales/ru.strings index 6faa5e2e..9ed4dcfb 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -184,6 +184,7 @@ "attach" = "Прикрепить"; "attach_photo" = "Прикрепить фото"; "attach_video" = "Прикрепить видео"; +"attach_geotag" = "Прикрепить геометку"; "draw_graffiti" = "Нарисовать граффити"; "no_posts_abstract" = "Здесь никто ничего не написал... Пока."; "attach_no_longer_available" = "Это вложение больше недоступно."; @@ -191,6 +192,11 @@ "version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK."; "graffiti" = "Граффити"; "reply" = "Ответить"; +"geotag" = "Геоточка"; +"nearest_posts" = "Ближайшие посты"; +"Latitude" = "Широта"; +"longitude" = "Долгота"; +"name_of_the_place" = "Название места"; /* Friends */ @@ -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 */