Added debug page, Improved Splide galleries
Update .gitignore, composer.php, and 12 more files...
This commit is contained in:
@@ -912,10 +912,10 @@ class ComposerElement {
|
||||
|
||||
case ComposerElementTypes::GALLERY:
|
||||
if(!is_null($this->srTitle)) {
|
||||
$htmlCode .= '<section class="splide border" aria-label="' . $this->srTitle . '">';
|
||||
$htmlCode .= '<section class="splide border bkgd-math" aria-label="' . $this->srTitle . '">';
|
||||
$htmlCode .= '<h2 id="carousel-heading">' . $this->srTitle . '</h2>';
|
||||
} else {
|
||||
$htmlCode .= '<section class="splide border">';
|
||||
$htmlCode .= '<section class="splide border bkgd-math">';
|
||||
}
|
||||
|
||||
$htmlCode .= '<div class="splide__track">';
|
||||
|
||||
@@ -15,6 +15,46 @@ $default_language = "en";
|
||||
$user_language = "en";
|
||||
$user_uri_language = "";
|
||||
|
||||
$lang_compilation_date = "1970-01-01T00:00:00Z";
|
||||
//$lang_compilation_date = (new DateTime('2010-12-30 23:21:46'))->format(DateTimeInterface::ATOM);
|
||||
|
||||
// Preparing a function for later
|
||||
function process_lang_header(string $accepted_lang_header, bool $filter_unsupported = true, bool $simplify_entries = true): array {
|
||||
$accepted_languages = [];
|
||||
|
||||
foreach(explode(",", $accepted_lang_header) as $_client_lang_entry) {
|
||||
$lang_entry_parts = explode(";", $_client_lang_entry);
|
||||
|
||||
// Ignoring entries without a "q=<float>" part
|
||||
if(count($lang_entry_parts) != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Simplifying complex entries from "en-US" to "en".
|
||||
// We'll ignore duplicates since it won't matter after sorting.
|
||||
if($simplify_entries && strlen($lang_entry_parts[0]) > 2) {
|
||||
$lang_entry_parts[0] = substr($lang_entry_parts[0], 0, 2);
|
||||
}
|
||||
|
||||
// Only allowing supported languages
|
||||
if(!in_array($lang_entry_parts[0], ["en", "fr"]) && $filter_unsupported) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parsing the language's weight
|
||||
$lang_entry_parts[1] = str_replace("q=", "", $lang_entry_parts[1]);
|
||||
$lang_entry_weights = filter_var($lang_entry_parts[1], FILTER_VALIDATE_FLOAT);
|
||||
if($lang_entry_weights === false || !is_float($lang_entry_weights)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Saving it for later
|
||||
$accepted_languages[] = $lang_entry_parts;
|
||||
}
|
||||
|
||||
return $accepted_languages;
|
||||
}
|
||||
|
||||
// Attempting to detect the language through the URI
|
||||
if(str_starts_with($_SERVER['REQUEST_URI'], "/en/")) {
|
||||
$user_language = "en";
|
||||
@@ -24,31 +64,7 @@ if(str_starts_with($_SERVER['REQUEST_URI'], "/en/")) {
|
||||
$user_uri_language = "/".$user_language;
|
||||
} elseif(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
// Attempting to detect the language through the browser's headers.
|
||||
$_client_languages = [];
|
||||
|
||||
foreach(explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]) as $_client_lang_entry) {
|
||||
$_client_lang_entry_parts = explode(";", $_client_lang_entry);
|
||||
|
||||
// Ignoring "en-US" and similar entries
|
||||
if(count($_client_lang_entry_parts) != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only allowing supported languages
|
||||
if(!in_array($_client_lang_entry_parts[0], ["en", "fr"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parsing the language's weight
|
||||
$_client_lang_entry_parts[1] = str_replace("q=", "", $_client_lang_entry_parts[1]);
|
||||
$_client_lang_entry_weight = filter_var($_client_lang_entry_parts[1], FILTER_VALIDATE_FLOAT);
|
||||
if($_client_lang_entry_weight === false || !is_float($_client_lang_entry_weight)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Saving it for later
|
||||
$_client_languages[] = $_client_lang_entry_parts;
|
||||
}
|
||||
$_client_languages = process_lang_header($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
|
||||
// Sorting based on weight and selecting the preferred one.
|
||||
if(count($_client_languages) > 0) {
|
||||
@@ -74,6 +90,10 @@ header("Content-Language: " . $user_language);
|
||||
$lang_json = file_get_contents(realpath($dir_commons . "/strings.json"));
|
||||
$lang_data = json_decode($lang_json, true);
|
||||
|
||||
if(array_key_exists("_compile_date", $lang_data)) {
|
||||
$lang_compilation_date = $lang_data["_compile_date"];
|
||||
}
|
||||
|
||||
// Localization functions
|
||||
function localize_private(string $string_key, array $private_lang_data, bool $fallback_to_common = false,
|
||||
string $fallback_prefix = "fallback.unknown") : string {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"common.action.copy": "Copy",
|
||||
"common.action.copied": "Copied"
|
||||
"common.action.copied": "Copied",
|
||||
|
||||
"common.undefined": "Undefined",
|
||||
"common.na": "N/A",
|
||||
|
||||
"common.yes": "Yes",
|
||||
"common.no": "No"
|
||||
}
|
||||
25
commons/strings/en/debug.json
Normal file
25
commons/strings/en/debug.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"debug.head.title": "Debugger - NibblePoker",
|
||||
"debug.head.description": "TODO: description",
|
||||
"debug.og.title": "NibblePoker - Debugger",
|
||||
"debug.og.description": "TODO: description",
|
||||
"debug.header.title": "Debugger",
|
||||
|
||||
"debug.tables.field": "Field",
|
||||
"debug.tables.value": "Value",
|
||||
|
||||
"debug.host.title": "Host Configuration",
|
||||
"debug.host.requested": "Requested",
|
||||
"debug.host.domain": "Domain",
|
||||
"debug.host.uri": "URI",
|
||||
"debug.host.tld": "TLD",
|
||||
"debug.host.waffle": "Waffle Mode",
|
||||
"debug.host.bouneschlupp": "Bouneschlupp Mode",
|
||||
|
||||
"debug.lang.title": "Localization System (L10N)",
|
||||
"debug.lang.compile-date": "Compilation date",
|
||||
"debug.lang.default": "Default language",
|
||||
"debug.lang.user": "Active language",
|
||||
"debug.lang.header.raw": "Raw HTTP header",
|
||||
"debug.lang.header.processed": "Processed HTTP header"
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"common.action.copy": "Copier",
|
||||
"common.action.copied": "Copié"
|
||||
"common.action.copied": "Copié",
|
||||
|
||||
"common.undefined": "Indéfini(e)",
|
||||
"common.na": "Non-applicable",
|
||||
|
||||
"common.yes": "Oui",
|
||||
"common.no": "Non"
|
||||
}
|
||||
25
commons/strings/fr/debug.json
Normal file
25
commons/strings/fr/debug.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"debug.head.title": "Débogueur - NibblePoker",
|
||||
"debug.head.description": "TODO: description",
|
||||
"debug.og.title": "NibblePoker - Débogueur",
|
||||
"debug.og.description": "TODO: description",
|
||||
"debug.header.title": "Débogueur",
|
||||
|
||||
"debug.tables.field": "Champ",
|
||||
"debug.tables.value": "Valeur",
|
||||
|
||||
"debug.host.title": "Configuration de l'hôte",
|
||||
"debug.host.requested": "Demandé",
|
||||
"debug.host.domain": "Domaine",
|
||||
"debug.host.uri": "URI",
|
||||
"debug.host.tld": "TLD",
|
||||
"debug.host.waffle": "Mode gaufrier",
|
||||
"debug.host.bouneschlupp": "Mode Bouneschlupp",
|
||||
|
||||
"debug.lang.title": "Système de localisation (L10N)",
|
||||
"debug.lang.compile-date": "Date de compilation",
|
||||
"debug.lang.default": "Langue par défaut",
|
||||
"debug.lang.user": "Langue active",
|
||||
"debug.lang.header.raw": "En-tête HTTP brut",
|
||||
"debug.lang.header.processed": "En-tête HTTP traité"
|
||||
}
|
||||
Reference in New Issue
Block a user