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
11 changes: 9 additions & 2 deletions _includes/2020/templates/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ private static function change_ui_language($language): string {
}

/**
* Render the globe dropdown for changing the UI language.
* As UI languages get added, we'll need to update this
* Render the globe dropdown for changing the UI language
* As UI languages get added, we'll need to update this.
* Limitation: Currently only visible on pages that use localized strings
* @param number - Div number, default 0.
*/
private static function render_globe_dropdown($number = 0): void {
global $page_is_using_locale;
if (!isset($page_is_using_locale) || !$page_is_using_locale) {
// only render on pages that use localized strings
return;
}

$divID = ($number == 1) ? "ui-language1" : "ui-language";
echo <<<END
<p>
Expand Down
2 changes: 1 addition & 1 deletion _includes/includes/ui/keyboard-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use \Keyman\Site\com\keyman\Locale;
use \Keyman\Site\com\keyman;

define('LOCALE_KEYBOARD_DETAILS', 'keyboards/details');
Locale::definePageLocale('LOCALE_KEYBOARD_DETAILS', 'keyboards/details');
$_m_KeyboardDetails = function($id, ...$args) {
return Locale::m(LOCALE_KEYBOARD_DETAILS, $id, ...$args);
};
Expand Down
12 changes: 12 additions & 0 deletions _includes/locale/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ public static function loadStrings($domain, $locale) {
}
}

/**
* Defines a global variable for page locale strings and also
* tells locale system that current page uses locales
* @param $define -
* @param $id - folder containing locale strings, relative to /_includes/locale/strings
*/
public static function definePageLocale($define, $id) {
global $page_is_using_locale;
$page_is_using_locale = true;
define($define, $id);
}

/**
* Given a locale, return an array of fallback locales
* For example: es-ES --> [es, es-ES]
Expand Down
2 changes: 1 addition & 1 deletion keyboards/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Keyman\Site\com\keyman\templates\Foot;
use Keyman\Site\com\keyman\Locale;

define('LOCALE_KEYBOARDS', 'keyboards');
Locale::definePageLocale('LOCALE_KEYBOARDS', 'keyboards');
$_m = function($id, ...$args) { return Locale::m(LOCALE_KEYBOARDS, $id, ...$args); };
function _m($id, ...$args) { return Locale::m(LOCALE_KEYBOARDS, $id, ...$args); }

Expand Down