aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2020-05-06 19:14:42 +0200
committerfilip <filip.komar@gmail.com>2020-05-06 19:14:42 +0200
commitdc9e76731b08732fd110fb80b874907704a984b6 (patch)
tree835f60c48a635a5f4ccb62e5d4d6671827d7e9df
parentbaa9325189ff28b4508068c4ac0db10712b0c58b (diff)
downloadwww-dc9e76731b08732fd110fb80b874907704a984b6.tar
www-dc9e76731b08732fd110fb80b874907704a984b6.tar.gz
www-dc9e76731b08732fd110fb80b874907704a984b6.tar.bz2
www-dc9e76731b08732fd110fb80b874907704a984b6.tar.xz
www-dc9e76731b08732fd110fb80b874907704a984b6.zip
finally i18n countries and cities in DL page + update infrastructure for that
-rw-r--r--en/downloads/get/index.php24
-rw-r--r--en/downloads/get/lib.php136
-rw-r--r--lib/Downloads.php48
-rw-r--r--tools/web_projects.dat2
4 files changed, 149 insertions, 61 deletions
diff --git a/en/downloads/get/index.php b/en/downloads/get/index.php
index 3ec90ebd2..add253c0f 100644
--- a/en/downloads/get/index.php
+++ b/en/downloads/get/index.php
@@ -33,9 +33,14 @@
*
*/
-require 'lib.php';
require_once '../../../lib/mga_geoip.php';
+define('HLANG', true);
+define('ALIGNMENT', 'Center');
+require '../../../langs.php';
+$dictionary = read_translation_file($locale, array('downloads/get', 'common_footer'));
+require 'lib.php';
+
// request
$product = get('q');
$doc = get('doc');
@@ -44,17 +49,11 @@ if (isset($_GET['torrent'])) {
$torrent = strip_tags(trim($_GET['torrent']));
}
$torrent = isset($torrent) ? true : false;
-
if (is_null($product)) {
header('Location: /downloads/');
die;
}
-define('HLANG', true);
-define('ALIGNMENT', 'Center');
-require '../../../langs.php';
-$dictionary = read_translation_file($locale, array('downloads/get', 'common_footer'));
-
session_start();
$download = null;
@@ -126,7 +125,12 @@ try {
$alt_dl_link, strtoupper($pm['scheme']), $pm['host']
);
}
- $s[] = sprintf('<td>%s</td><td>%s</td>', rewrite_city($city), implode(', ', $mirs));
+ if ("-" == $city) {
+ $city = _r("City not set");
+ }
+ $s[] = sprintf('<td>%s</td><td>%s</td>',
+ (isset($cities_i18n[$city])) ? $cities_i18n[$city] : $city,
+ implode(', ', $mirs));
}
$alternative_mirrors .= sprintf('<tr><td rowspan="%d">%s</td>%s</tr>' . PHP_EOL, count($cities), $country, implode('</tr><tr>', $s));
}
@@ -143,8 +147,8 @@ try {
_r('This <a href="%s">%s</a> download mirror is located in %s (%s).', ' '),
$one_mirror['mirror_url'],
$one_mirror['mirror_host'],
- rewrite_city($one_mirror['city']),
- $mirrors_country_name
+ ("-" == $one_mirror['city']) ? $mirrors_country_name : $one_mirror['city'],
+ ("-" == $one_mirror['city']) ? _r("City not set") : $mirrors_country_name
);
$dl2_mirror_alt .= _r('If it does not work well for you, <a href="#om" id="other_mirrors_btn">check out these other mirrors</a>.', ' ');
if (array_key_exists($_SESSION['country'], $countries)) {
diff --git a/en/downloads/get/lib.php b/en/downloads/get/lib.php
index 7f720cb08..a479a1f91 100644
--- a/en/downloads/get/lib.php
+++ b/en/downloads/get/lib.php
@@ -9,46 +9,93 @@
* @link http://www.mageia.org/
*
*/
-// _r('');
// note, we use geographical country names
-$countries = array(
- 'AR' => 'Argentina',
- 'AU' => 'Australia',
- 'BE' => 'Belgique',
- 'BG' => 'България - Bulgaria',
- 'BR' => 'Brasil',
- 'BY' => 'Беларусь - Belarus',
- 'CA' => 'Canada',
- 'CH' => 'Switzerland',
- 'CN' => '中国 - China',
- 'CZ' => 'Česko', // Czechia
- 'DE' => 'Deutschland',
- 'DK' => 'Danmark',
- 'EC' => 'Ecuador',
- 'ES' => 'España',
- 'FR' => 'France',
- 'GB' => 'Great Britain',
- 'GR' => 'Ελλάδα - Greece',
- 'GT' => 'Guatemala',
- 'ID' => 'Indonesia',
- 'IL' => 'Israel',
- 'IT' => 'Italia',
- 'JP' => '日本国 - Japan',
- 'NC' => 'Nouvelle-Calédonie',
- 'NL' => 'Nederlands',
- 'PH' => 'Philipines',
- 'PL' => 'Polska',
- 'RU' => 'Россия - Russia',
- 'SE' => 'Sverige',
- 'TR' => 'Türkiye',
- 'TW' => '臺灣 - Taiwan',
- 'UA' => 'Ukraine',
- 'UK' => 'the UK',
- 'US' => 'the USA',
- 'VN' => 'Vietnam',
- 'ZA' => 'South Africa'
+$countries = array (
+ 'AR' => _r("Argentina"),
+ 'AU' => _r("Australia"),
+ 'BE' => _r("Belgique"),
+ 'BG' => _r("България - Bulgaria"),
+ 'BR' => _r("Brasil"),
+ 'BY' => _r("Беларусь - Belarus"),
+ 'CA' => _r("Canada"),
+ 'CH' => _r("Switzerland"),
+ 'CN' => _r("中国 - China"),
+ 'CZ' => _r("Česko"),
+ 'DE' => _r("Deutschland"),
+ 'DK' => _r("Danmark"),
+ 'EC' => _r("Ecuador"),
+ 'ES' => _r("España"),
+ 'FR' => _r("France"),
+ 'GB' => _r("Great Britain"),
+ 'GR' => _r("Ελλάδα - Greece"),
+ 'GT' => _r("Guatemala"),
+ 'HU' => _r("Hungary"),
+ 'ID' => _r("Indonesia"),
+ 'IL' => _r("Israel"),
+ 'IT' => _r("Italia"),
+ 'JP' => _r("日本国 - Japan"),
+ 'NC' => _r("Nouvelle-Calédonie"),
+ 'NL' => _r("Nederlands"),
+ 'PH' => _r("Philipines"),
+ 'PL' => _r("Polska"),
+ 'RU' => _r("Россия - Russia"),
+ 'SE' => _r("Sverige"),
+ 'TR' => _r("Türkiye"),
+ 'TW' => _r("臺灣 - Taiwan"),
+ 'UA' => _r("Ukraine"),
+ 'UK' => _r("the UK"),
+ 'US' => _r("the USA"),
+ 'VN' => _r("Vietnam"),
+ 'ZA' => _r("South Africa"),
);
+$cities_i18n = array (
+ 'Adelaide' => _r("Adelaide"),
+ 'Amsterdam' => _r("Amsterdam"),
+ 'Ankara' => _r("Ankara"),
+ 'Beauharnois' => _r("Beauharnois"),
+ 'Beijing' => _r("Beijing"), // '北京', // .cn
+ 'Brasilia' => _r("Brasilia"),
+ 'Brisbane' => _r("Brisbane"),
+ 'Brno' => _r("Brno"),
+ 'Brussels' => _r("Brussels"),
+ 'Canterbury' => _r("Canterbury"),
+ 'Cebu' => _r("Cebu"),
+ 'Chungli' => _r("Chungli"),
+ 'Cuenca' => _r("Cuenca"),
+ 'DTU' => _r("DTU"),
+ 'Durham' => _r("Durham"),
+ 'Düsseldorf' => _r("Düsseldorf"),
+ 'Enschede' => _r("Enschede"),
+ 'Erlangen' => _r("Erlangen"),
+ 'Falkenstein/Vogtl.' => _r("Falkenstein/Vogtl."),
+ 'Göttingen' => _r("Göttingen"),
+ 'Heraklion' => _r("Heraklion"), // 'Ηράκλειο', // .gr
+ 'HsinChu' => _r("HsinChu"), // '新竹市', // .tw
+ 'Lenoir' => _r("Lenoir"),
+ 'Lyon' => _r("Lyon"),
+ 'Milan' => _r("Milan"),
+ 'Minsk' => _r("Minsk"), // 'Мінск', // .by
+ 'Miskolc' => _r("Miskolc"),
+ 'Moscow' => _r("Moscow"), // 'Москва', // .ru
+ 'Paris' => _r("Paris"),
+ 'Prague' => _r("Prague"), // 'Praha', // .cz
+ 'Princeton' => _r("Princeton"),
+ 'Schneverdingen' => _r("Schneverdingen"),
+ 'Shanghai' => _r("Shanghai"),
+ 'Sofia' => _r("Sofia"),
+ 'Stellenbosch' => _r("Stellenbosch"),
+ 'Taipei' => _r("Taipei"),
+ 'Tsukuba' => _r("Tsukuba"),
+ 'Umeå' => _r("Umeå"),
+ 'Vinnytsia' => _r("Vinnytsia"),
+ 'Warszawa' => _r("Warszawa"),
+ 'Yonezawa' => _r("Yonezawa"), // '米沢市', // .jp
+ 'ruchmond' => _r("ruchmond"),
+ 'Краснодар' => _r("Краснодар"),
+);
+
+
/**
* Rewrite city name in the local official language.
*
@@ -56,19 +103,10 @@ $countries = array(
*
* @return string
*/
-function rewrite_city($name)
+function rewrite_city($name, $cities_for_rewrite)
{
- $cities = array(
- 'HsinChu' => '新竹市', // .tw
- 'Yonezawa' => '米沢市', // .jp
- 'Beijing' => '北京', // .cn
- 'Moscow' => 'Москва', // .ru
- 'Minsk' => 'Мінск', // .by
- 'Heraklion' => 'Ηράκλειο', // .gr
- 'Prague' => 'Praha', // .cz
- );
- if (array_key_exists($name, $cities)) {
- return $cities[$name];
+ if (array_key_exists($name, $cities_for_rewrite)) {
+ return $cities_for_rewrite[$name];
}
return $name;
diff --git a/lib/Downloads.php b/lib/Downloads.php
index fc8305c06..5d1e676f8 100644
--- a/lib/Downloads.php
+++ b/lib/Downloads.php
@@ -153,6 +153,14 @@ class Downloads
$mirrors = array();
$num_up = 0;
$num_dn = 0;
+ $mirror_cities = array();
+ $mirror_countries = array();
+ $refresh_country_and_city_arrays = false;
+ if ($prod == false && $documentation == false && $mirrorlist == false) {
+ function _r($passthru) {return '_r("' . $passthru . '")';};
+ include_once(realpath(__DIR__) . '/../en/downloads/get/lib.php');
+ $refresh_country_and_city_arrays = true;
+ }
foreach ($data as $line) {
$line = explode(',', trim($line));
$m = array();
@@ -167,10 +175,25 @@ class Downloads
$item = array(
'zone' => isset($m['zone']) ? $m['zone'] : '?',
'country' => isset($m['country']) ? $m['country'] : '?',
- 'city' => isset($m['city']) ? utf8_encode($m['city']) : '-',
+ 'city' => isset($m['city']) ? $m['city'] : '-',
// BEWARE of the path substitution here. Must match.
'url' => str_replace('/distrib/7/i586', '', $m['url'])
);
+ if ($refresh_country_and_city_arrays == true) {
+ // prepare details for i18n
+ if (isset($m['city'])) {
+ if (isset($cities_i18n[$m['city']])) {
+ $mirror_cities[$m['city']] = $cities_i18n[$m['city']];
+ } else {
+ $mirror_cities[$m['city']] = '_r("' . $m['city'] . '") // new city (not yet in /en/downloads/get/lib.php)';
+ }
+ }
+ if (isset($countries[$item['country']])) {
+ $mirror_countries[$item['country']] = $countries[$item['country']];
+ } else if (isset($item['country'])) {
+ $mirror_countries[$item['country']] = " // new country (not yet in /en/downloads/get/lib.php)";
+ }
+ }
if ($documentation) {
$test_file = $item['url'].'/doc/mga7/date.txt';
@@ -199,6 +222,29 @@ class Downloads
echo "\nThere are $num_up servers with the file and $num_dn with some kind of issue.\n";
file_put_contents($cache_file,
sprintf('<?php $mirrors = %s; ?>' . PHP_EOL, var_export($mirrors, true)));
+
+ if ($refresh_country_and_city_arrays == true) {
+ foreach ($countries as $ISO_3166_country_code => $lib_country) {
+ if (!isset($mirror_countries[$ISO_3166_country_code])) {
+ $mirror_countries[$ISO_3166_country_code] = $lib_country;
+ }
+ }
+ foreach ($cities_i18n as $english_name => $translated_name) {
+ if (!isset($mirror_cities[$english_name])) {
+ $mirror_cities[$english_name] = '_r("' . $english_name . '")';
+ }
+ }
+ ksort($mirror_cities);
+ $countries_u = array_unique($mirror_countries);
+ ksort($countries_u);
+ echo "\nArray of cities for i18n: ";
+ var_export($mirror_cities);
+ echo ";\nArray of countries for i18n: ";
+ var_export($countries_u);
+ echo ";\n";
+ }
+ echo "\nRemove char ' at each value on both arrays for cities and countries above : replace '_r(\" with just _r( and also behind \")', with \"),\n";
+ echo "and update arrays in file /en/downloads/get/lib.php with that.\n";
}
return $mirrors;
}
diff --git a/tools/web_projects.dat b/tools/web_projects.dat
index 23c34c0a8..babfb6b2c 100644
--- a/tools/web_projects.dat
+++ b/tools/web_projects.dat
@@ -7,7 +7,7 @@ resources[about/media]="en/about/media/index.php"
resources[about/policies/privacy]="en/about/policies/privacy/index.php"
resources[about/reports]="en/about/reports/index.php"
resources[about/values]="en/about/values/index.php"
-resources[downloads/get]="en/downloads/get/index.php"
+resources[downloads/get]="en/downloads/get/index.php en/downloads/get/lib.php"
resources[2]="en/2/download_index.php en/2/for-pc/index.php en/2/for-server/index.php en/2/index.php en/2/nav.php"
resources[3]="en/3/download_index.php en/3/for-pc/index.php en/3/for-server/index.php en/3/index.php en/3/nav.php"