diff --git a/_includes/locale/Locale.php b/_includes/locale/Locale.php index a763ec3..eaf6cad 100644 --- a/_includes/locale/Locale.php +++ b/_includes/locale/Locale.php @@ -69,13 +69,11 @@ public static function setTextDomain($basename) { } /** - * Returns an array of localized strings from the specified $domain-locale.po file + * Reads localized strings from the specified $domain-locale.po file * for the current locale. * @param $domain - base filename of the .po files (not including -xx-YY locale) - * @param $strings - Array of msgid's in the .po files - * @return Array of localized strings for the current locale */ - public static function localize($domain, $strings) { + public static function localize($domain) { foreach(Locale::CROWDIN_LOCALES as $l) { if ($l == Locale::DEFAULT_LOCALE) { // Skip English @@ -86,16 +84,7 @@ public static function localize($domain, $strings) { } $previousTextDomain = textdomain(NULL); - Locale::setTextDomain($domain); - - $result = []; - foreach($strings as $s) { - $result[$s] = _($s); - } - - // Restore textdomain - textdomain($previousTextDomain); - return $result; + Locale::setTextDomain($domain); } /** @@ -104,6 +93,6 @@ public static function localize($domain, $strings) { * @param $args - optional remaining args to the format string */ public static function _s($s, ...$args) { - return vsprintf($s, $args); + return vsprintf(_($s), $args); } } diff --git a/_includes/locale/en/LC_MESSAGES/keyboards-en.po b/_includes/locale/en/LC_MESSAGES/keyboards-en.po index d08becd..d2465b0 100644 --- a/_includes/locale/en/LC_MESSAGES/keyboards-en.po +++ b/_includes/locale/en/LC_MESSAGES/keyboards-en.po @@ -28,9 +28,9 @@ msgstr "Search" msgid "New search" msgstr "New search" -# Search box prompt -msgid "Enter the name of a keyboard or language to search for%1$s" -msgstr "Enter the name of a keyboard or language to search for%1$s" +# Search box instruction (Popular keyboards | All keyboards) +msgid "Enter the name of a keyboard or language to search for" +msgstr "Enter the name of a keyboard or language to search for" # Search box link for popular keyboards msgid "Popular keyboards" diff --git a/_includes/locale/en/LC_MESSAGES/keyboards-es-ES.po b/_includes/locale/en/LC_MESSAGES/keyboards-es-ES.po index ea0e852..ef6416a 100644 --- a/_includes/locale/en/LC_MESSAGES/keyboards-es-ES.po +++ b/_includes/locale/en/LC_MESSAGES/keyboards-es-ES.po @@ -36,9 +36,9 @@ msgstr "Buscar" msgid "New search" msgstr "Nueva buscar" -# Search box prompt -msgid "Enter the name of a keyboard or language to search for%1$s" -msgstr "Introduzca el nombre de un teclado o idioma para buscar%1$s" +# Search box instruction (Popular keyboards | All keyboards) +msgid "Enter the name of a keyboard or language to search for" +msgstr "Introduzca el nombre de un teclado o idioma para buscar" # Search box link for popular keyboards msgid "Popular keyboards" diff --git a/_includes/locale/en/LC_MESSAGES/keyboards-fr-FR.po b/_includes/locale/en/LC_MESSAGES/keyboards-fr-FR.po index bb16414..f88339f 100644 --- a/_includes/locale/en/LC_MESSAGES/keyboards-fr-FR.po +++ b/_includes/locale/en/LC_MESSAGES/keyboards-fr-FR.po @@ -36,9 +36,9 @@ msgstr "Recherche" msgid "New search" msgstr "Nouvelle recherche" -# Search box prompt -msgid "Enter the name of a keyboard or language to search for%1$s" -msgstr "Saisissez le nom d'un clavier ou d'une langue à rechercher%1$s" +# Search box instruction (Popular keyboards | All keyboards) +msgid "Enter the name of a keyboard or language to search for%" +msgstr "Saisissez le nom d'un clavier ou d'une langue à rechercher" # Search box link for popular keyboards msgid "Popular keyboards" diff --git a/keyboards/index.php b/keyboards/index.php index 7adfe49..41e6191 100644 --- a/keyboards/index.php +++ b/keyboards/index.php @@ -9,34 +9,11 @@ use Keyman\Site\com\keyman\templates\Foot; use Keyman\Site\com\keyman\Locale; - // Of array of strings at top of file - // by msgid - $keyboardIndexStrings = Locale::localize('keyboards', [ - 'Keyboard Search', - 'Keyman Keyboard Search', - 'Keyboard search:', - 'Enter language or keyboard', - 'Search', - 'New search', - 'Enter the name of a keyboard or language to search for%1$s', - 'Popular keyboards', - 'All keyboards', - 'Hints', - 'The search always returns a list of keyboards. It searches for keyboard names and details, language names, country names and script names.', - 'You can apply prefixes', - '(keyboards)', - '(languages)', - '(scripts, writing systems) or', - '(countries) to filter your search results. For example', - 'searches for keyboards for languages used in Thailand.', - 'Use prefix', - 'to search for a BCP 47 language tag, for example', - 'searches for Tigrigna (Ethiopia)', - ]); + Locale::localize('keyboards'); $head_options = [ - 'title' => $keyboardIndexStrings['Keyboard Search'], - 'description' => $keyboardIndexStrings['Keyman Keyboard Search'], + 'title' => _('Keyboard Search'), + 'description' => _('Keyman Keyboard Search'), 'language' => Locale::currentLocale(), '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'), @@ -73,14 +50,14 @@
'> -

+