From 599da8594764267745b413ab87ebce1fdf8ac96d Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Tue, 10 Jan 2023 15:54:42 +0100 Subject: [PATCH] Localization changes --- lang/ca.ini | 48 ++++++++++++++++++++++++++++++--- lang/en.ini | 47 ++++++++++++++++++++++++++++++--- lang/es.ini | 47 ++++++++++++++++++++++++++++++--- lang/{fu.ini => fu} | 2 +- utils/localization.php | 60 ++++++++++++++++++++++-------------------- 5 files changed, 162 insertions(+), 42 deletions(-) rename lang/{fu.ini => fu} (91%) diff --git a/lang/ca.ini b/lang/ca.ini index 37fcee0..7f826f0 100755 --- a/lang/ca.ini +++ b/lang/ca.ini @@ -17,10 +17,50 @@ contact = "Contacte" programming = "Programació" git = "Perfil git" -keys = "Claus" - # main page -welcome = "Text per ocupar el espai" +welcomeHeader = "Yepa!" +welcome = " +

Hola i benvingudi a la meua pàgina

+

+ Ací allotje les coses que fet així com + les que estic fent actualment, opinions + candents, coses que crec que mereixen ser + compartides i coses que me representen com + persona. +

+ +

+ Si vols saber més de mí pots vore-ho + ací o pots contactar-me. +

+ +

+ Espere que trobes coses que siguen del teu interés. +

+ " + +projectsHeader = "Projects" +projects = " +

fai.st

+

+ Allotje i administre una sèrie de serveis de programari + lliure (un servidor fediversal, una instancia de Gitea, servei + VPN...) amb el nomb de fai.st amb uns amics. +

+ +

USG

+

+ Clon competitiu del Tetris que busca ser correcte. Realitzat en + el llenguatge zig y amb la llibreria de SDL i renderització OpenGL. + Majoritariament fet el propòsit de aprendre. +

+ +

keno

+

+ Client i biblioteca per a consumir la API de Mastodon gastant GTK i C. + Actualmen no està en desevolupament actiu. +

+ " # footer -copyright = "Aquesta pàgina està baix la llicència GPLv3 i el seu codi font estarà diponible prompte™. Els recursos utilitzats en aquesta pàgina estan baix CC-SA si no se especifica lo contrari." +copyright = "Aquesta pàgina està baix la llicència GPLv3 i el seu codi font estarà diponible prompte™. Els recursos utilitzats en aquesta pàgina estan baix CC-BY-NC-SA si no se especifica lo contrari." diff --git a/lang/en.ini b/lang/en.ini index 685bb96..bfd6450 100755 --- a/lang/en.ini +++ b/lang/en.ini @@ -16,10 +16,49 @@ contact = "Contact" programming = "Programming" git = "Git profile" -keys = "Keys" - # main page -welcome = "Text to occupy space" +welcomeHeader = "Hi" +welcome = " +

Hello and welcome to my place!

+

+ Here I'm hosting the things I've done, + thing's im currently doing, my hot takes + and things that I think are worth sharing + and represent who I am as a being +

+ +

+ If you want to know more about me you + can see it here or contact me. +

+ +

+ Hope you find something that interests you. +

+ " + +projectsHeader = "Projects" +projects = " +

fai.st

+

+ I host and manage a number of free software services + (a fediverse server, Gitea instance, VPN...) + under the name fai.st alongside some friends. +

+ +

USG

+

+ Proper competitive tetris clone made in ziglang and SDL2, + with OpenGL rendering. Mostly made for learning purposes. +

+ +

keno

+

+ Mastodon-API client and library using C and GTK. Not under + active development anymore. +

+ " + # footer -copyright = "This website is under the GPLv3 license and its source code will be avalible soon™. The resources used on this website are under CC-SA unless stated otherwise." +copyright = "This website is under the GPLv3 license and its source code will be avalible soon™. The resources used on this website are under CC-BY-NC-SA unless stated otherwise." diff --git a/lang/es.ini b/lang/es.ini index 19b37e8..6060222 100755 --- a/lang/es.ini +++ b/lang/es.ini @@ -17,10 +17,49 @@ contact = "Contacto" programming = "Programación" git = "Perfil git" -keys = "Claves" - # main page -welcome = "Texto para ocupar espacio" +welcomeHeader = "¡Buenas!" +welcome = " +

Hola y bienvenide a mi página

+

+ Aquí alojo las cosas que hecho así como + las que estoy actualmente haciendo, opiniones + candentes, cosas que creo que vale la pena + compartir y cosas que me representan como persona. +

+ +

+ Si quieres saber más sobre mí lo puedes ver + aquí o puedes contactarme. +

+ +

+ Espero que encuentres cosas que te sean de interés. +

+ " + +projectsHeader = "Projects" +projects = " +

fai.st

+

+ Alojo y administro una serie de servicios sofware libre + (un servidor fediversal, una instancia de Gitea, servicio VPN...) + bajo el nombre fai.st con unos amigos. +

+ +

USG

+

+ Clon competitivo del Tetris de implementación correcta realizado + en ziglang y SDL2, con renderización mediante OpenGL. Mayoritariamente + hecho con el propósito de aprender. +

+ +

keno

+

+ Cliente y biblioteca para consumir la API de Mastodon usando GTK y C. + Actualmente no está en desarrollo activo. +

+ " # footer -copyright = "Esta página está bajo la licencia GPLv3 y su código fuente estará diponible pronto™. Los recursos usados en esta página están bajo CC-SA a no ser que se diga lo contrario." +copyright = "Esta página está bajo la licencia GPLv3 y su código fuente estará diponible pronto™. Los recursos usados en esta página están bajo CC-BY-NC-SA a no ser que se diga lo contrario." diff --git a/lang/fu.ini b/lang/fu similarity index 91% rename from lang/fu.ini rename to lang/fu index 5cf9101..08af773 100755 --- a/lang/fu.ini +++ b/lang/fu @@ -22,4 +22,4 @@ keys = "Kweys" welcome = "Tewxt to occupy spwace >:3c" # footer -copyright = "Twis website is unwer the GPLv3 wicense and its sowwse code avawwable soon™. De wesources used on this webwsite are under CC-SA unwess stated oderwise. UwU" +copyright = "Twis website is unwer the GPLv3 wicense and its sowwse code avawwable soon™. De wesources used on this webwsite are under CC-BY-NC-SA unwess stated oderwise. UwU" diff --git a/utils/localization.php b/utils/localization.php index e782fb2..bee66ac 100755 --- a/utils/localization.php +++ b/utils/localization.php @@ -1,7 +1,7 @@ preg_match('/.*\.ini/', $x) === 1); + // Filter for those that have two letters and end in ".ini" + $langs = array_filter($langs, fn ($x) => preg_match('/.*\.ini/', $x) === 1); // And we remove the ".ini" part - $langs = array_map(fn($x) => substr($x, 0, 2), $langs); + $langs = array_map(fn ($x) => substr($x, 0, 2), $langs); - //////////////////////////////////// - /// Get the optimal language to use + //////////////////////////////////// + /// Get the optimal language to use //////////////////////////////////// /* Try to get the language from browser-sent headers. The * format for the header is like this: "en_US,es;q=0.5,ar;q=0.1". * q=N represents the weight of preference, no q means q=1.0. */ - { + if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? false) { // Divide language string per language $http_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); // Sanitize lang string and cast weight - $http_langs = array_map(function($x){ - $x = explode(';',$x); + $http_langs = array_map(function ($x) { + $x = explode(';', $x); $x[0] = strtolower(substr($x[0], 0, 2)); - $x[1] = (float)(explode('=',$x[1]??'q=1.0')[1]??1.0); + $x[1] = (float)(explode('=', $x[1] ?? 'q=1.0')[1] ?? 1.0); return $x; }, $http_langs); // Sort by weight - usort($http_langs, function($a, $b){ - if($a[1] === $b[1]) return 0; + usort($http_langs, function ($a, $b) { + if ($a[1] === $b[1]) return 0; return ($a[1] > $b[1]) ? -1 : 1; }); // Create new neat array like this: ['en', 'es', 'ar'] $user_langs = []; - array_walk($http_langs, function($arr) use (&$user_langs){ - if(!in_array($arr[0], $user_langs)) $user_langs[] = $arr[0]; + array_walk($http_langs, function ($arr) use (&$user_langs) { + if (!in_array($arr[0], $user_langs)) $user_langs[] = $arr[0]; }); // Assign the first match - foreach($user_langs as $ilang){ - if(in_array($ilang, $langs)) { + foreach ($user_langs as $ilang) { + if (in_array($ilang, $langs)) { $lang = $ilang; break; } } - } // Manully selected lang > HTTP lang > fallback lang - $lang = ($_GET['lang']??null) ?: $lang ?: 'en'; + $lang = ($_GET['lang'] ?? null) ?: $lang ?: 'en'; - /////////////////////////////////////////////////// - /// Get file and build function to get the strings + /////////////////////////////////////////////////// + /// Get file and build function to get the strings /////////////////////////////////////////////////// $text = parse_ini_file("$basedir/$lang.ini", true); - $trans = function (string $index) use ($text): string{ - return htmlspecialchars($text[$index]??"N/A", ENT_QUOTES); + $trans = function (string $index) use ($text): string { + // return htmlspecialchars($text[$index] ?? 'N/A', ENT_QUOTES); + return $text[$index] ?? 'N/A'; }; };