4
4
require_once ('includes/template.php ' );
5
5
require_once ('includes/playstore.php ' );
6
6
require_once ('includes/appstore.php ' );
7
+ require_once __DIR__ . '/../../../keyboards/session.php ' ;
7
8
8
9
use \DateTime ;
9
10
use \Keyman \Site \com \keyman \KeymanWebHost ;
10
11
use \Keyman \Site \Common \KeymanHosts ;
12
+ use Keyman \Site \com \keyman \Locale ;
11
13
14
+ Locale::localize ('keyboards-details ' );
15
+
12
16
define ('GITHUB_ROOT ' , 'https://github.com/keymanapp/keyboards/tree/master/ ' );
13
17
define ('DOCUMENTATION_ROOT ' , KeymanHosts::Instance ()->help_keyman_com . '/keyboard/ ' );
14
18
@@ -107,10 +111,13 @@ protected static function download_box($platform) {
107
111
$ h_filename = htmlspecialchars ($ filename );
108
112
$ platformTitle = self ::platformTitles[$ platform ];
109
113
114
+ // Get the localized strings to pass to heredoc syntax
115
+ $ install_keyboard = _ ('Install keyboard ' );
116
+ $ install_keyboard_description = Locale::_s ('Installs %1$s for %2$s on this device ' , $ h_filename , $ platformTitle );
110
117
return <<<END
111
118
<div class="download download- $ platform">
112
- <a class='download-link binary-download' href=' $ installLink'><span>Install keyboard </span></a>
113
- <div class="download-description">Installs { $ h_filename } for $ platformTitle on this device </div>
119
+ <a class='download-link binary-download' href=' $ installLink'><span> $ install_keyboard </span></a>
120
+ <div class="download-description"> $ install_keyboard_description </div>
114
121
</div>
115
122
END ;
116
123
} else {
@@ -155,11 +162,13 @@ protected static function WriteWebBoxes($useDescription) {
155
162
$ url = "{$ KeymanHosts ->keymanweb_com }/# $ lang,Keyboard_ " . self ::GetWebKeyboardId ();
156
163
if ($ useDescription ) {
157
164
$ description = htmlentities (self ::$ keyboard ->name );
158
- $ description = "<div class= \"download-description \">Use $ description in your web browser. No need to install anything.</div> " ;
159
- $ linktext = 'Use keyboard online ' ;
165
+ $ useKeyboardDescription = Locale::_s ('Use %1$s in your web browser. No need to install anything. ' , $ description );
166
+ $ description = "<div class= \"download-description \">
167
+ $ useKeyboardDescription</div> " ;
168
+ $ linktext = _ ('Use keyboard online ' );
160
169
} else {
161
170
$ description = '' ;
162
- $ linktext = 'Full online editor ' ;
171
+ $ linktext = _ ( 'Full online editor ' ) ;
163
172
}
164
173
return <<<END
165
174
<div class="download download-web">
@@ -177,7 +186,7 @@ protected static function LoadData() {
177
186
if ($ s === FALSE ) {
178
187
// Will fail later in the script
179
188
self ::$ error .= error_get_last ()['message ' ] . "\n" ;
180
- self ::$ title = 'Failed to load keyboard package ' . self ::$ id ;
189
+ self ::$ title = Locale:: _s ( 'Failed to load keyboard package %1$s ' , self ::$ id) ;
181
190
header ('HTTP/1.0 404 Keyboard not found ' );
182
191
} else {
183
192
$ s = json_decode ($ s );
@@ -190,19 +199,19 @@ protected static function LoadData() {
190
199
self ::$ minVersion = isset (self ::$ keyboard ->minKeymanVersion ) ? self ::$ keyboard ->minKeymanVersion : $ stable_version ;
191
200
self ::$ license = self ::map_license (isset (self ::$ keyboard ->license ) ? self ::$ keyboard ->license : 'Unknown ' );
192
201
} else {
193
- self ::$ error .= " Error returned from { $ KeymanHosts ->api_keyman_com } : $ s \n" ;
194
- self ::$ title = 'Failed to load keyboard package ' . self ::$ id ;
202
+ self ::$ error .= Locale:: _s ( ' Error returned from %1$s: %2$s ' , $ KeymanHosts ->api_keyman_com , " $ s \n") ;
203
+ self ::$ title = Locale:: _s ( 'Failed to load keyboard package %1%s ' , self ::$ id) ;
195
204
header ('HTTP/1.0 500 Internal Server Error ' );
196
205
}
197
206
}
198
207
199
208
if (!empty (self ::$ keyboard )) {
200
209
if (in_array ('unicode ' , self ::$ keyboard ->encodings ) && in_array ('ansi ' , self ::$ keyboard ->encodings ))
201
- self ::$ keyboardEncoding = 'Unicode, Legacy (ANSI) ' ;
210
+ self ::$ keyboardEncoding = _ ( 'Unicode, Legacy (ANSI) ' ) ;
202
211
else if (in_array ('unicode ' , self ::$ keyboard ->encodings ))
203
- self ::$ keyboardEncoding = 'Unicode ' ;
212
+ self ::$ keyboardEncoding = _ ( 'Unicode ' ) ;
204
213
else // ansi
205
- self ::$ keyboardEncoding = 'Legacy (ANSI) ' ;
214
+ self ::$ keyboardEncoding = _ ( 'Legacy (ANSI) ' ) ;
206
215
207
216
$ date = new DateTime (self ::$ keyboard ->lastModifiedDate );
208
217
self ::$ keyboardLastModifiedDate = $ date ->format ('Y-m-d H:i ' );
@@ -307,7 +316,7 @@ protected static function WriteTitle() {
307
316
// If parameters are missing ...
308
317
?>
309
318
<h1 class='red underline'><?= self ::$ id ?> </h1>
310
- <p>Keyboard package <?= self ::$ id ?> not found. </p>
319
+ <p><?= Locale:: _s ( ' Keyboard package %1$s not found. ' , self ::$ id) ?> </p>
311
320
<?php
312
321
// DEBUG: Only display errors on local sites
313
322
global $ KeymanHosts ;
@@ -321,7 +330,7 @@ protected static function WriteTitle() {
321
330
?>
322
331
323
332
<div id='search-box'>
324
- <label id='search-new'><a href='/keyboards<?= $ session_query_q ?> '>New search</a></label>
333
+ <label id='search-new'><a href='/keyboards<?= $ session_query_q ?> '><?= _ ( ' New search ' ) ?> </a></label>
325
334
<h1 class='red'><?= self ::$ title ?> </h1>
326
335
</div>
327
336
@@ -331,9 +340,9 @@ protected static function WriteTitle() {
331
340
332
341
<div id='search-box'>
333
342
<form method='get' action='/keyboards' name='f'>
334
- <input id="search-q" type="text" placeholder="New keyboard search" name="q">
343
+ <input id="search-q" type="text" placeholder="<?= _ ( ' New keyboard search ' ) ?> " name="q">
335
344
<input id='search-page' type='hidden' name='page'>
336
- <input id="search-f" type="image" src="<?= cdn ('img/search-button.png ' ) ?> " value="Search">
345
+ <input id="search-f" type="image" src="<?= cdn ('img/search-button.png ' ) ?> " value="<?= _ ( ' Search ' ) ?> ">
337
346
</form>
338
347
</div>
339
348
<?php
@@ -349,11 +358,14 @@ protected static function WriteTitle() {
349
358
$ dep = self ::$ deprecatedBy ;
350
359
echo "
351
360
<div>
352
- <a href='/keyboards/ $ dep$ session_query_q' class='deprecated'><span>Important note:</span>
353
- This is an obsolete version of this keyboard. Unless you have a good reason, click here to install the new version, called <span> $ dep</span>, instead.</a>
361
+ <a href='/keyboards/ $ dep$ session_query_q' class='deprecated'>
362
+ <span> " . _ ('Important note: ' ) . " </span> " .
363
+ _ ('This is an obsolete version of this keyboard. Unless you have a good reason, click here to install the new version, called ' ) .
364
+ " <span> $ dep</span> " . _ (', instead. ' ) . "</a>
354
365
</div>
355
366
<div>
356
- <p class='deprecated-link'><a href='javascript:toggleDeprecatedVersionDetails()'>View details for obsolete version instead</a></p>
367
+ <p class='deprecated-link'><a href='javascript:toggleDeprecatedVersionDetails()'> " .
368
+ _ ('View details for obsolete version instead ' ) . "</a></p>
357
369
<div id='deprecated-old'>
358
370
359
371
" ;
@@ -378,7 +390,7 @@ protected static function WriteDownloadBoxes() {
378
390
379
391
if ($ embed_win && isset (self ::$ keyboard ->minKeymanVersion ) && version_compare (self ::$ keyboard ->minKeymanVersion , $ embed_version ) > 0 ) {
380
392
?>
381
- <p>Sorry, this keyboard requires Keyman <?= self ::$ keyboard ->minKeymanVersion ?> or higher. </p>
393
+ <p><?= Locale:: _s ( " Sorry, this keyboard requires Keyman %1 $ s or higher. " , self ::$ keyboard ->minKeymanVersion ) ?> </p>
382
394
<?php
383
395
} else {
384
396
echo $ text ;
@@ -446,7 +458,7 @@ protected static function WriteKeymanWebBox() {
446
458
$ webtext = self ::WriteWebBoxes (false );
447
459
$ cdnUrlBase = KeymanWebHost::getKeymanWebUrlBase ();
448
460
?>
449
- <h2 id='try-header' class='red underline'>Try this keyboard</h2>
461
+ <h2 id='try-header' class='red underline'><?= _ ( ' Try this keyboard ' ) ?> </h2>
450
462
<div id='try-box'>
451
463
<input type='text' id='try-keyboard'>
452
464
<div id='osk-host'></div>
@@ -486,45 +498,46 @@ protected static function WriteKeyboardDetails() {
486
498
487
499
// this is html, trusted in database
488
500
?>
489
- <h2 class='red underline'>Keyboard Details</h2>
501
+ <h2 class='red underline'><?= _ ( " Keyboard Details " ) ?> </h2>
490
502
<div class='cols' id='keyboard-details-col'>
491
503
<div class='col'>
492
504
493
505
<table id='keyboard-details'>
494
506
<tbody>
495
507
<tr>
496
- <th>Keyboard ID</th>
508
+ <th><?= _ ( " Keyboard ID " ) ?> </th>
497
509
<td><?= htmlentities (self ::$ id ) ?> </td>
498
510
</tr>
499
511
<tr>
500
- <th>Supported Platforms</th>
512
+ <th><?= _ ( " Supported Platforms " ) ?> </th>
501
513
<td><?= self ::$ keyboardPlatforms ?> </td>
502
514
</tr>
503
515
<tr>
504
- <th>Author</th>
516
+ <th><?= _ ( " Author " ) ?> </th>
505
517
<td><?= htmlentities (self ::$ authorName ) ?> </td>
506
518
</tr>
507
519
<tr>
508
- <th>License</th>
520
+ <th><?= _ ( " License " ) ?> </th>
509
521
<td><?= self ::$ license ?> </td>
510
522
</tr>
511
523
<tr>
512
- <th>Documentation</th>
524
+ <th><?= _ ( " Documentation " ) ?> </th>
513
525
<td>
514
526
<?php
515
527
if (isset (self ::$ keyboard ->helpLink )) {
516
528
?>
517
529
<a <?= $ embed_target ?>
518
- href='<?= self ::$ keyboard ->helpLink ?> '>Keyboard help</a>
530
+ href='<?= self ::$ keyboard ->helpLink ?> '><?= _ ( " Keyboard help " ) ?> </a>
519
531
<?php
520
532
} else {
521
- echo "Help not available. " ;
533
+ $ helpNotAvailable = _ ('Help not available. ' );
534
+ echo $ helpNotAvailable ;
522
535
}
523
536
?>
524
537
</td>
525
538
</tr>
526
539
<tr>
527
- <th>Source</th>
540
+ <th><?= _ ( " Source " ) ?> </th>
528
541
<td>
529
542
<?php
530
543
if (isset (self ::$ keyboard ->sourcePath ) && preg_match ('/^(release|experimental)\// ' , self ::$ keyboard ->sourcePath )) {
@@ -533,15 +546,15 @@ protected static function WriteKeyboardDetails() {
533
546
href='<?= GITHUB_ROOT . htmlentities (self ::$ keyboard ->sourcePath ) ?> '><?= htmlentities (self ::$ keyboard ->sourcePath ) ?> </a>
534
547
<?php
535
548
} else {
536
- echo "Source not available. " ;
549
+ echo _ ( "Source not available. " ) ;
537
550
} ?>
538
551
</td>
539
552
<tr>
540
- <th>Keyboard Version</th>
553
+ <th><?= _ ( " Keyboard Version " ) ?> </th>
541
554
<td><?= htmlentities (self ::$ keyboard ->version ) ?> </td>
542
555
</tr>
543
556
<tr>
544
- <th>Last Updated</th>
557
+ <th><?= _ ( " Last Updated " ) ?> </th>
545
558
<td><?= self ::$ keyboardLastModifiedDate ?> </td>
546
559
</tr>
547
560
</tbody>
@@ -556,31 +569,31 @@ protected static function WriteKeyboardDetails() {
556
569
if (isset (self ::$ keyboard ->packageFilename )) {
557
570
?>
558
571
<tr>
559
- <th>Package Download</th>
572
+ <th><?= _ ( " Package Download " ) ?> </th>
560
573
<td><a href="<?= self ::$ kmpDownloadUrl ?> " rel="nofollow"><?= self ::$ keyboard ->id ?> .kmp</a></td>
561
574
</tr>
562
575
<?php
563
576
}
564
577
?>
565
578
<tr>
566
- <th>Monthly Downloads</th>
579
+ <th><?= _ ( " Monthly Downloads " ) ?> </th>
567
580
<td><?= number_format (self ::$ downloadCount ) ?> </td>
568
581
</tr>
569
582
<tr>
570
- <th>Total Downloads</th>
571
- <td title='Downloads since October 2019'><?= number_format (self ::$ totalDownloadCount ) ?> </td>
583
+ <th><?= _ ( " Total Downloads " ) ?> </th>
584
+ <td title='<?= Locale:: _s ( ' Downloads since %1$s ' , " October 2019 " ) ?> '><?= number_format (self ::$ totalDownloadCount ) ?> </td>
572
585
</tr>
573
586
<tr>
574
- <th>Encoding</th>
587
+ <th><?= _ ( " Encoding " ) ?> </th>
575
588
<td><?= self ::$ keyboardEncoding ?> </td>
576
589
</tr>
577
590
<tr>
578
- <th>Minimum Keyman Version</th>
591
+ <th><?= Locale:: _s ( ' Minimum %1$s Version ' , " Keyman " ) ?> </th>
579
592
<td><?= self ::$ minVersion ?> </td>
580
593
</tr>
581
594
<?php if (isset (self ::$ keyboard ->related )) { ?>
582
595
<tr>
583
- <th>Related Keyboards</th>
596
+ <th><?= _ ( " Related Keyboards " ) ?> </th>
584
597
<td>
585
598
<?php
586
599
foreach (self ::$ keyboard ->related as $ name => $ value ) {
@@ -590,19 +603,25 @@ protected static function WriteKeyboardDetails() {
590
603
// schema.
591
604
$ s = @file_get_contents ($ KeymanHosts ->api_keyman_com . '/keyboard/ ' . rawurlencode ($ name ));
592
605
if ($ s === FALSE ) {
593
- echo "<span class='keyboard-unavailable' title='This keyboard is not available on {$ KeymanHosts ->keyman_com_host }'> $ hname</span> " ;
606
+ echo "<span class='keyboard-unavailable' title=' " .
607
+ Locale::_s ('This keyboard is not available on %1$s ' , $ KeymanHosts ->keyman_com_host ) .
608
+ "'> $ hname</span> " ;
594
609
} else {
595
610
echo "<a href='/keyboards/ $ hname$ session_query_q'> $ hname</a> " ;
596
611
}
597
- if (isset ($ value ->deprecates ) && $ value ->deprecates ) echo " (deprecated) " ;
598
- if (isset ($ value ->deprecatedBy ) && $ value ->deprecatedBy ) echo " (new version) " ;
612
+ if (isset ($ value ->deprecates ) && $ value ->deprecates ) {
613
+ echo _ ('(deprecated) ' );
614
+ }
615
+ if (isset ($ value ->deprecatedBy ) && $ value ->deprecatedBy ) {
616
+ echo _ ('(new version) ' );
617
+ }
599
618
}
600
619
?>
601
620
</td>
602
621
</tr>
603
622
<?php } ?>
604
623
<tr>
605
- <th>Supported Languages</th>
624
+ <th><?= _ ( " Supported Languages " ) ?> </th>
606
625
<td class='supported-languages'>
607
626
<?php
608
627
(function () {
@@ -615,8 +634,10 @@ protected static function WriteKeyboardDetails() {
615
634
616
635
foreach ($ langs as $ bcp47 => $ detail ) {
617
636
if ($ n == 3 ) {
618
- echo " <a id='expand-languages' href='#expand-languages'>Expand $ count more >></a> " ;
619
- echo "<a id='collapse-languages' href='#collapse-languages'><< Collapse</a> <span class='expand-languages'> " ;
637
+ echo " <a id='expand-languages' href='#expand-languages'> " .
638
+ Locale::_s ('Expand %1$s more >> ' , $ count ) . "</a> " ;
639
+ echo "<a id='collapse-languages' href='#collapse-languages'> " .
640
+ _ ('<< Collapse ' ) . "</a> <span class='expand-languages'> " ;
620
641
}
621
642
if (property_exists ($ detail , 'languageName ' )) {
622
643
echo
@@ -642,7 +663,7 @@ protected static function WriteKeyboardDetails() {
642
663
</div>
643
664
644
665
<p id='permalink'>
645
- Permanent link to this keyboard:
666
+ <?= _ ( " Permanent link to this keyboard: " ) ?>
646
667
<a <?= $ embed_target ?> href='<?= KeymanHosts::Instance ()->keyman_com ?> /keyboards/<?= self ::$ keyboard ->id ?> '>
647
668
<?= KeymanHosts::Instance ()->keyman_com ?> /keyboards/<?= self ::$ keyboard ->id ?>
648
669
</a>
@@ -654,7 +675,7 @@ protected static function WriteQRCode($context) {
654
675
?>
655
676
<div class='qrcode-host qrcode-<?= $ context?> '>
656
677
<div id="qrcode-<?= $ context?> "></div>
657
- <div class='qrcode-caption'>Scan this code to load this keyboard on another device</div>
678
+ <div class='qrcode-caption'><?= _ ( " Scan this code to load this keyboard on another device " ) ?> </div>
658
679
</div>
659
680
<script type="text/javascript">
660
681
new QRCode(document.getElementById("qrcode-<?= $ context?> "), {
0 commit comments