diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 0511514dc..6ff87b548 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -45,5 +45,6 @@ public function boot(): void
Blade::include('components.comments', 'comments');
Blade::include('components.solutions', 'solutions');
Blade::include("components.solution", 'solution');
+ Blade::include("components.hreflang_tags", 'hreflang_tags');
}
}
diff --git a/app/View/Components/HreflangTags.php b/app/View/Components/HreflangTags.php
new file mode 100644
index 000000000..96699e51f
--- /dev/null
+++ b/app/View/Components/HreflangTags.php
@@ -0,0 +1,48 @@
+generateLanguageUrls();
+ }
+
+ private function generateLanguageUrls(): void
+ {
+ $defaultLocale = config('app.locale');
+ $this->currentLocale = app()->getLocale();
+ $segments = request()->segments();
+
+ $url = implode('/', $segments);
+
+ if ($this->currentLocale !== $defaultLocale) {
+ $url = "$this->currentLocale/$url";
+ }
+
+ if ($this->currentLocale === 'ru') {
+ $this->languageUrls['en'] = $this->removeLanguagePrefixes($url);
+ } else {
+ $this->languageUrls['ru'] = "ru/$url";
+ }
+
+ $this->languageUrls['x-default'] = $this->removeLanguagePrefixes($url);
+ }
+
+ public function removeLanguagePrefixes(string $url): string
+ {
+ return preg_replace('/(^\/ru\/?|\/ru\/?|\/?ru\/?|\/$)/u', '', $url);
+ }
+
+ public function render(): View
+ {
+ return view('components.hreflang_tags', ['languageUrls' => $this->languageUrls, 'currentLocale' => $this->currentLocale]);
+ }
+}
diff --git a/resources/views/components/hreflang_tags.blade.php b/resources/views/components/hreflang_tags.blade.php
new file mode 100644
index 000000000..8dee5bf28
--- /dev/null
+++ b/resources/views/components/hreflang_tags.blade.php
@@ -0,0 +1,3 @@
+@foreach ($languageUrls as $language => $url)
+
+@endforeach
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php
index e5fcd64d8..141927688 100644
--- a/resources/views/layouts/app.blade.php
+++ b/resources/views/layouts/app.blade.php
@@ -24,6 +24,7 @@
@includeWhen(app()->environment('production'), 'layouts.deps._gtm_body')
@includeWhen(app()->environment('production'), 'layouts.deps._metrika')
+