Commit 8580aafa authored by Carl Schwan's avatar Carl Schwan 🚴🏻

feat(i18n): Add site_locale parameter to change language

And translate more content
parent 3aca5664
......@@ -2,14 +2,17 @@ RewriteBase /applications/
# NOTE: we'll skip all rules if the path is an icons path!
RewriteCond %{REQUEST_FILENAME} "^.*/icons/.*"
RewriteRule .? - [S=5]
RewriteRule .? - [S=6]
# ... and also skip fonts.
RewriteCond %{REQUEST_FILENAME} "^.*/fonts/.*"
RewriteRule .? - [S=4]
RewriteRule .? - [S=5]
RewriteCond %{REQUEST_FILENAME} "^.*/assets/.*"
RewriteRule .? - [S=4]
RewriteCond %{REQUEST_FILENAME} "^.*/thumbnails/.*"
RewriteRule .? - [S=3]
# Rewrite the application and category pages
RewriteRule ^([\w]+)/?$ applicationlist.php?category=$1 [NS,PT]
RewriteRule ^([\w]+)/([^\/]+)/? applicationpage.php?category=$1&application=$2&%{QUERY_STRING} [NS,PT]
RewriteRule ^([\w]+)/([^\/]+)/?$ applicationpage.php?category=$1&application=$2 [NS,PT]
RewriteRule ^([\w]+)/([^\/]+)/development/?$ applicationpage.php?category=$1&application=$2&development=true [NS,PT]
......@@ -176,7 +176,7 @@ function printPage($app, $category)
///TODO: Versions not yet implemented
}
if ($app->hasLicense()) {
print '<h2>License</h2>';
print '<h2>'.i18n('License').'</h2>';
print $app->licenseHtml();
}
}
......@@ -184,9 +184,9 @@ function printPage($app, $category)
function printDevelopmentPage($app, $category)
{
print '<h2>Source Code Repository</h2>';
print '<h2>'.i18n('Source Code Repository').'</h2>';
if ($category == 'unmaintained') {
if ($category === 'unmaintained') {
print "<p><b>This app is unmaintained and no longer released by the KDE community.</b></p>";
return;
}
......@@ -212,10 +212,10 @@ function printDevelopmentPage($app, $category)
$juniorJobs = 'https://bugs.kde.org/buglist.cgi?keywords=junior-jobs&product='.$product.$componentstring.'&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&cmdtype=doit';
print '<ul>';
print '<li><a href="'.htmlspecialchars($majorBugs).'">Major Bug reports</a></li>';
print '<li><a href="'.htmlspecialchars($minorBugs).'">Minor Bug reports</a></li>';
print '<li><a href="'.htmlspecialchars($wishes).'">Wish reports</a></li>';
print '<li><a href="'.htmlspecialchars($juniorJobs).'">Junior Jobs</a></li>';
print '<li><a href="'.htmlspecialchars($majorBugs).'">'.i18n('Major Bug reports').</a></li>';
print '<li><a href="'.htmlspecialchars($minorBugs).'">'.i18n('Minor Bug reports').</a></li>';
print '<li><a href="'.htmlspecialchars($wishes).'">'.i18n('Wish reports').'</a></li>';
print '<li><a href="'.htmlspecialchars($juniorJobs).'">'.i18n('Junior Jobs').'</a></li>';
print '</ul>';
}
......
......@@ -402,7 +402,7 @@ class AppData
if ($screenshot['source-image']['lang'] === $lang) {
$screenshotRet = [
'thumbnails' => '../'.$screenshot['thumbnails'][0]['url'],
'thumbnails' => '/applications'.$screenshot['thumbnails'][0]['url'],
'source-image' => $screenshot['source-image']['url'],
'default' => isset($screenshot['default']) && $screenshot['default'] == true
];
......
<?php
/**
* kde-org-applications
* Copyright (C) 2019 Carl Schwan <carl at carlschwan dot eu>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'Category.php';
/**
* This class is a wrapper around index.json
*/
class Applications
{
private $data;
private $appDataBuilder;
public function __construct(array $data, AppDataBuilder $appDataBuilder)
{
$this->data = $data;
$this->appDataBuilder = $appDataBuilder;
}
public function getCategories(): Generator
{
foreach ($this->data as $categoryName => $applicationNames) {
yield new Category($categoryName, $applicationNames, $appDataBuilder);
}
}
}
<?php
/**
* kde-org-applications
* Copyright (C) 2019 Carl Schwan <carl at carlschwan dot eu>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class Category
{
private $categoryName;
private $applicationNames;
private $appDataBuilder;
public function __construct(string $categoryName, string $applicationNames, AppDataBuilder $appDataBuilder)
{
$this->categoryName = $categoryName;
$this->applicationNames = $applicationNames;
}
public function getApplications()
{
return $appDataBuilder->loadCategory($applicationNames);
}
}
......@@ -26,6 +26,10 @@ class Intl
if (empty($acceptedLanguages)) {
$acceptedLanguages = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
}
if (isset($_GET["site_locale"])) {
$this->clientPreferredLanguages = [htmlspecialchars($_GET["site_locale"]), "C"];
return;
}
// print_r($acceptedLanguages); print_r("<br/>");
// regex inspired from @GabrielAnderson on http://stackoverflow.com/questions/6038236/http-accept-language
......
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