Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed lang/af/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/af/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/af/flag.jpg
Binary file not shown.
Binary file removed lang/ar/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/ar/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/ar/flag.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/es_AR/LC_MESSAGES/homepage.mo
Binary file not shown.
1,508 changes: 0 additions & 1,508 deletions lang/es_AR/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/es_AR/flag.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/fil/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/fil/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/fil/flag.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/gl/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/gl/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/gl/flag.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/id/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/id/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/id/flag.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/kab/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/kab/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/kab/flag.jpg
Binary file not shown.
Binary file removed lang/ko/LC_MESSAGES/homepage.mo
Binary file not shown.
1,465 changes: 0 additions & 1,465 deletions lang/ko/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/ko/flag.jpg
Binary file not shown.
Binary file removed lang/lt/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/lt/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/lt/flag.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/no/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/no/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/no/flag.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/pt_PT/LC_MESSAGES/homepage.mo
Binary file not shown.
1,382 changes: 0 additions & 1,382 deletions lang/pt_PT/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/pt_PT/flag.jpg
Diff not rendered.
Binary file removed lang/ro/LC_MESSAGES/homepage.mo
Binary file not shown.
1,348 changes: 0 additions & 1,348 deletions lang/ro/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/ro/flag.jpg
Diff not rendered.
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/sk/LC_MESSAGES/homepage.mo
Binary file not shown.
1,335 changes: 0 additions & 1,335 deletions lang/sk/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/sk/flag.jpg
Diff not rendered.
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/sr_CS/LC_MESSAGES/homepage.mo
Binary file not shown.
1,508 changes: 0 additions & 1,508 deletions lang/sr_CS/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/sr_CS/flag.jpg
Diff not rendered.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
Binary file removed lang/val_ES/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/val_ES/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/val_ES/flag.jpg
Diff not rendered.
Binary file removed lang/vi/LC_MESSAGES/homepage.mo
Binary file not shown.
1,327 changes: 0 additions & 1,327 deletions lang/vi/LC_MESSAGES/homepage.po

This file was deleted.

Binary file removed lang/vi/flag.jpg
Diff not rendered.
7 changes: 3 additions & 4 deletions localeMap.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"de": "de_DE",
"sl": "sl_SI",
"hr": "hr_HR",
"zh": "zh_TW",
"zh_TW": "zh_TW",
"el": "el_GR",
"es": "es_ES",
"fa": "fa_IR",
Expand All @@ -22,9 +22,8 @@
"uk": "uk_UA",
"zh_CN": "zh_CN",
"cs": "cs_CZ",
"pt": "pt_BR",
"pt_BR": "pt_BR",
"es_CO": "es_CO",
"eu": "eu_ES",
"sr": "sr_RS",
"sr_RS": "sr_RS"
"sr": "sr_RS"
}
29 changes: 10 additions & 19 deletions translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ function loadLocaleMap($filePath)
return $localeMap;
}

$localeMap = loadLocaleMap(__DIR__ . '/localeMap.json');

function getFlags($href = '/')
{
$localeMap = loadLocaleMap(__DIR__ . '/localeMap.json');
global $localeMap;

// Default English entry
echo('<a class="dropdown-item" href="' . $href . '">
Expand All @@ -28,34 +30,23 @@ function getFlags($href = '/')
if ($shortCode === 'en') {
continue;
}
$localeObj = locale_get_display_language($locale, $locale);
if (!$localeObj) {
$localeObj = $locale; // fallback
}

$localeName = locale_get_display_language($locale, $locale) ?: $locale;
echo('<a class="dropdown-item" href="' . $href . '?lang=' . $shortCode . '">
<img src="lang/' . $shortCode . '/flag.jpg" alt="" />' . _($localeObj) . '</a>');
<img src="lang/' . $locale . '/flag.jpg" alt="" />' . htmlentities($localeName) . '</a>');
}
}

$lang = $_GET['lang'] ?? '';
$lang = preg_match('@^[a-z]{2}(?:_[A-Z]{2})?$@', $lang) ? $lang : 'en';
$localeMap = loadLocaleMap(__DIR__ . '/localeMap.json');
$lang = $_GET['lang'] ?? "en";
$localeMapFlip = array_flip($localeMap);
$locale = $localeMap[$lang] ?? $lang;
$lang = $localeMapFlip[$locale] ?? "en";
if ($lang == "en") $locale = "en";
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("homepage", "lang");
textdomain("homepage");
bind_textdomain_codeset("homepage", 'UTF-8');

$flagcode = $lang;

if (!file_exists('lang/'.$flagcode."/flag.jpg")) {
if (strpos($flagcode, '_') !== false) {
$flagcode = explode("_", $flagcode)[0];
}
}
$flagcode = $locale;
$langStr = "?lang=" . urlencode($lang);
$langattrib = "&lang=" . urlencode($lang);

?>
Loading