Commit 9b5a5281 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Add translations bar

parent db296090
Pipeline #25096 passed with stage
in 2 minutes and 54 seconds
......@@ -23,11 +23,20 @@ function import_po_files # First parameter will be a path that will contain seve
lang=`basename $translation`
msgattrib --translated --no-fuzzy --no-obsolete -o "translations/messages.${lang}" "$translation"
done
# print the obsolete translations
cp config/services.php.in config/services.php
for translation in translations/messages.*.po; do
# print the obsolete translations
langpo=`basename $translation | sed -e 's,^messages\.,,g'`
if [ ! -e "$podir/$langpo" ]; then
echo "WARNING: $translation has no more backing po file in l10n"
fi
# generate data for language bar
echo "$translation" | sed 's/[^\.]*\.\([^\.]*\)\.po$/"\1",/g' >> config/services.php
done
echo "]);" >> config/services.php
}
......@@ -13,3 +13,16 @@ foreach (\ResourceBundle::getLocales('') as $name) {
}
$container->setParameter('app.locales', implode('|', $localeRequirements));
$container->setParameter('app.translations', [
"ca",
"de",
"es",
"eu",
"fr",
"it",
"pt",
"sk",
"uk",
]);
<?php
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
//
// SPDX-License-Identifier: CC0-1.0
// Generate locale requirement
\Locale::setDefault('en');
$localeRequirements = [];
foreach (\ResourceBundle::getLocales('') as $name) {
$localeRequirements[] = $name;
}
$container->setParameter('app.locales', implode('|', $localeRequirements));
$container->setParameter('app.translations', [
......@@ -41,7 +41,8 @@ class MainController extends AbstractController
return $this->render('main/index.html.twig', [
'categories' => $applicationsProvider->getAllCategories(),
'locale' => $_locale
'locale' => $_locale,
'translations' => $this->getParameter('app.translations'),
]);
}
......@@ -68,6 +69,9 @@ class MainController extends AbstractController
]);
}
$applicationObj = AppData::fromBinary($category);
if ($applicationObj === null) {
return new Response(200, $category);
}
return $this->redirectToRoute('app_main_application_intl', [
'_locale' => $_locale,
'category' => strtolower($applicationObj->getPrimaryCategory()),
......
......@@ -14,6 +14,15 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<main class="container">
<h1>{% trans %}KDE's Applications{% endtrans %}</h1>
<p>
{% for translation in translations %}
<a href="{{ path('app_main_index', {'_locale': translation}) }}">{{ translation | language_name(translation) | capitalize}}</a>
{% if not loop.last %}
|
{% endif %}
{% endfor %}
</p>
<p>{% trans %}KDE is a community of friendly people who create over 200 apps which run on any Linux desktop, and often other platforms too. Here is the complete list.{% endtrans %}</p>
<div class="form-group">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment