From 689d15b183bbc29b288ecde43814642a3e083ddd Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 9 Sep 2025 09:47:50 +0700 Subject: [PATCH 01/18] feat: Use associate array for strings on keyboard search page --- _includes/autoload.php | 6 +- _includes/includes/template.php | 3 + _includes/locale/Locale.php | 112 ++++++++++++++++++ .../locale/en/LC_MESSAGES/keyboards-en.php | 76 ++++++++++++ .../locale/en/LC_MESSAGES/keyboards-es-ES.php | 75 ++++++++++++ .../locale/en/LC_MESSAGES/keyboards-fr-FR.php | 75 ++++++++++++ keyboards/index.php | 27 +++-- keyboards/session.php | 7 ++ 8 files changed, 368 insertions(+), 13 deletions(-) create mode 100644 _includes/locale/Locale.php create mode 100644 _includes/locale/en/LC_MESSAGES/keyboards-en.php create mode 100644 _includes/locale/en/LC_MESSAGES/keyboards-es-ES.php create mode 100644 _includes/locale/en/LC_MESSAGES/keyboards-fr-FR.php diff --git a/_includes/autoload.php b/_includes/autoload.php index 29c7493c..f8321aa9 100644 --- a/_includes/autoload.php +++ b/_includes/autoload.php @@ -5,7 +5,11 @@ if(preg_match('/^Keyman\\\\Site\\\\com\\\\keyman\\\\(.+)/', $class_name, $matches)) { // Fix namespace pathing for Linux $filename = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $matches[1]); - $success = include(__DIR__ . "/2020/{$filename}.php"); + if ($filename != 'Locale') { + $success = include(__DIR__ . "/2020/{$filename}.php"); + } else { + $success = include(__DIR__ . "/locale/{$filename}.php"); + } if($success === FALSE) { debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); die("Unable to find class $class_name"); diff --git a/_includes/includes/template.php b/_includes/includes/template.php index 57e87a81..3abc2485 100644 --- a/_includes/includes/template.php +++ b/_includes/includes/template.php @@ -3,9 +3,12 @@ // *Don't* use autoloader here because of potential side-effects in older pages require_once(__DIR__ . '/../2020/Util.php'); + require_once(__DIR__ . '/../locale/Locale.php'); require_once(__DIR__ . '/../../_common/KeymanVersion.php'); require_once(__DIR__ . '/../2020/templates/Head.php'); + use Keyman\Site\com\keyman\Locale; + function template_finish($foot) { //ob_end_flush(); diff --git a/_includes/locale/Locale.php b/_includes/locale/Locale.php new file mode 100644 index 00000000..3da92cbc --- /dev/null +++ b/_includes/locale/Locale.php @@ -0,0 +1,112 @@ + "Keyboard Search", + + # Page Description + "page_description" => "Keyman Keyboard Search", + + # Keyboard search bar + "keyboard_search" => "Keyboard search:", + + # Search bar placeholder + "enter_language" => "Enter language or keyboard", + + # Search Button Value + "search" => "Search", + + # Link to start a new keyboard search + "new_search" => "New search", + + # Search box instruction (Popular keyboards | All keyboards) + "enter_name" => "Enter the name of a keyboard or language to search for", + + # Search box link for popular keyboards + "popular_keyboards" => "Popular keyboards", + + # Search box link for all Keyman keyboards + "all_keyboards" => "All keyboards", + + # Search box hint: List header + "hints" => "Hints", + + # Search box hint: Description + "searchbox_description" => + "The search always returns a list of keyboards. It searches for keyboard names and details, language names, country names and script names.", + + # Search box hint: available prefixes to use in the search + "searchbox_hint" => "You can apply prefixes", + + # (keyboards) + "(keyboards)" => "(keyboards)", + + # (languages) + "(languages)" => "(languages)", + + # (scripts, writing systems) or... + "(scripts, writing systems) or" => "(scripts, writing systems) or", + + # (countries) to filter your search results... + "(countries) to filter your search results. For example" => + "(countries) to filter your search results. For example", + + # Search box hint: example of country search + "searches for keyboards for languages used in Thailand." => + "searches for keyboards for languages used in Thailand.", + + # Search box hint: BCP 47 prefix + "use_prefix" => "Use prefix", + + # Seach box hint: BCP 47 language example + "to search for a BCP 47 language tag, for example" => + "to search for a BCP 47 language tag, for example", + + # Search box hint: BCP 47 language example + "searches_tigrigna" => "searches for Tigrigna (Ethiopia)." + +]; diff --git a/_includes/locale/en/LC_MESSAGES/keyboards-es-ES.php b/_includes/locale/en/LC_MESSAGES/keyboards-es-ES.php new file mode 100644 index 00000000..23c73342 --- /dev/null +++ b/_includes/locale/en/LC_MESSAGES/keyboards-es-ES.php @@ -0,0 +1,75 @@ + "Búsqueda por Teclado", + + # Page Description + "page_description" => "Keyman Búsqueda por Teclado", + + # Keyboard search bar + "keyboard_search" => "Búsqueda por teclado:", + + # Search bar placeholder + "enter_language" => "Ingresar idioma o teclado", + + # Search Button Value + "search" => "Buscar", + + # Link to start a new keyboard search + "new_search" => "Nueva buscar", + + # Search box instruction (Popular keyboards | All keyboards) + "enter_name" => "Introduzca el nombre de un teclado o idioma para buscar", + + # Search box link for popular keyboards + "popular_keyboards" => "Teclados populares", + + # Search box link for all Keyman keyboards + "all_keyboards" => "Todos los teclados", + + # Search box hint: List header + "hints" => "Consejos", + + # Search box hint: Description + "searchbox_description" => + "La búsqueda siempre devuelve una lista de teclados. Busca nombres de teclados y detalles, nombres de idiomas, nombres de países y nombres de alfabetos.", + + # Search box hint: available prefixes to use in the search + "searchbox_hint" => "Puedes aplicar prefijos", + + # (keyboards) + "(keyboards)" => "(tescados)", + + # (languages) + "(languages)" => "(idiomas)", + + # (scripts, writing systems) or... + "(scripts, writing systems) or" => "(guiones, sistemas de escritura) o", + + # (countries) to filter your search results... + "(countries) to filter your search results. For example" => + "(países) para filtrar los resultados de búsqueda. Por ejemplo", + + # Search box hint: example of country search + "searches for keyboards for languages used in Thailand." => + "busca teclados para los idiomas utilizados en Tailandia.", + + # Search box hint: BCP 47 prefix + "use_prefix" => "Utilice prefijo", + + # Seach box hint: BCP 47 language example + "to search for a BCP 47 language tag, for example" => + "para buscar una etiqueta de idioma BCP 47, por ejemplo", + + # Search box hint: BCP 47 language example + "searches_tigrigna" => "busca Tigrigna (Etiopía).", + +]; diff --git a/_includes/locale/en/LC_MESSAGES/keyboards-fr-FR.php b/_includes/locale/en/LC_MESSAGES/keyboards-fr-FR.php new file mode 100644 index 00000000..4538fd70 --- /dev/null +++ b/_includes/locale/en/LC_MESSAGES/keyboards-fr-FR.php @@ -0,0 +1,75 @@ + "Recherche au clavier", + + # Page Description + "page_description" => "Recherche de clavier Keyman", + + # Keyboard search bar + "keyboard_search" => "Recherche au clavier:", + + # Search bar placeholder + "enter_language" => "Entrez la langue ou le clavier", + + # Search Button Value + "search" => "Recherche", + + # Link to start a new keyboard search + "new_search" => "Nouvelle recherche", + + # Search box instruction (Popular keyboards | All keyboards) + "enter_name" => "Saisissez le nom d'un clavier ou d'une langue à rechercher", + + # Search box link for popular keyboards + "popular_keyboards" => "Claviers populaires", + + # Search box link for all Keyman keyboards + "all_keyboards" => "Tous les claviers", + + # Search box hint: List header + "hints" => "Conseils", + + # Search box hint: Description + "searchbox_description" => + "La recherche renvoie toujours une liste de claviers. Elle recherche les noms et les détails des claviers, les noms de langues, les noms de pays et les noms d'écritures.", + + # Search box hint: available prefixes to use in the search + "searchbox_hint" => "Vous pouvez appliquer des préfixes", + + # (keyboards) + "(keyboards)" => "(claviers)", + + # (languages) + "(languages)" => "(langues)", + + # (scripts, writing systems) or... + "(scripts, writing systems) or" => "(scripts, systèmes d'écriture) ou", + + # (countries) to filter your search results... + "(countries) to filter your search results. For example" => + "(pays) pour filtrer vos résultats de recherche. Par exemple", + + # Search box hint: example of country search + "searches for keyboards for languages used in Thailand." => + "recherche des claviers pour les langues utilisées en Thaïlande.", + + # Search box hint: BCP 47 prefix + "use_prefix" => "Utiliser le préfixe", + + # Seach box hint: BCP 47 language example + "to search for a BCP 47 language tag, for example" => + "pour rechercher une balise de langue BCP 47, par exemple", + + # Search box hint: BCP 47 language example + "searches_tigrigna" => "recherche Tigrigna (Ethiopie)." + +]; diff --git a/keyboards/index.php b/keyboards/index.php index c188fa85..afa81505 100644 --- a/keyboards/index.php +++ b/keyboards/index.php @@ -7,10 +7,13 @@ use Keyman\Site\com\keyman\templates\Menu; use Keyman\Site\com\keyman\templates\Body; use Keyman\Site\com\keyman\templates\Foot; + use Keyman\Site\com\keyman\Locale; + + Locale::localize('keyboards'); $head_options = [ - 'title' =>'Keyboard Search', - 'description' => 'Keyman Keyboard Search', + 'title' =>Locale::_m('page_title'), + 'description' => Locale::_m('page_description'), 'css' => [Util::cdn('css/template.css'), Util::cdn('keyboard-search/search.css')], 'js' => [Util::cdn('keyboard-search/jquery.mark.js'), Util::cdn('keyboard-search/dedicated-landing-pages.js'), Util::cdn('keyboard-search/search.js')] @@ -46,14 +49,14 @@
'> -

Keyboard Search

+

diff --git a/cdn/dev/img/globe.png b/cdn/dev/img/globe.png new file mode 100644 index 0000000000000000000000000000000000000000..a27673ef1ec7ecc271305c45bc8a89b258560990 GIT binary patch literal 700 zcmV;t0z>_YP)6#W~;1JMVmY;N|--dKoh#OL@dW7gm& zEU1wvcm{j$QD)MP@3E{#>|z|jvlxX9_y*&v0S$%VMVN)Z@QxVXM7)d%CEzic$U6Lq z5txQ0_<)$cyx5H=5}4@iQ#gvdCE$9zC>Zif`q~rkO)*^X5`GjtZb2(P!8VLbU-27@ z&H1&a?^XPa8O2s~;W|#>a{8ME11{kIQpUpse>(*u?g~o&gDLo-E(2R|1Gn;Aho&sG z7KQHP-;AkZ+|CxXC^+xs|4IpIZ-2AQHjl~P1?4mVclIZP}^i9pgP8UmU!p;Ql%MwSS4QCADPlhZXt21Tp=6VuDMEQcnoQ4zY)CFN(Rav&KCD0000
+
+
+

Globe icon courtesy of Adnen Kadri, under + Creative Commons Attribution 3.0 Unported licence.

+
+
+
  • English
  • -
  • French - Français
  • -
  • Spanish - Español
  • +
  • Español
  • +
  • Français
  • diff --git a/_includes/autoload.php b/_includes/autoload.php index f8321aa9..792c20f1 100644 --- a/_includes/autoload.php +++ b/_includes/autoload.php @@ -5,10 +5,10 @@ if(preg_match('/^Keyman\\\\Site\\\\com\\\\keyman\\\\(.+)/', $class_name, $matches)) { // Fix namespace pathing for Linux $filename = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $matches[1]); - if ($filename != 'Locale') { - $success = include(__DIR__ . "/2020/{$filename}.php"); - } else { + if ($filename == 'Locale') { $success = include(__DIR__ . "/locale/{$filename}.php"); + } else { + $success = include(__DIR__ . "/2020/{$filename}.php"); } if($success === FALSE) { debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); diff --git a/index.php b/index.php index 6e9cb249..1e4ce950 100644 --- a/index.php +++ b/index.php @@ -49,6 +49,7 @@

    +