-
-
Notifications
You must be signed in to change notification settings - Fork 141
docs(web): improve documentation on addKeyboards/addKeyboardsForLanguage
#16020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,57 +4,80 @@ title: Adding Keyboards | |
|
|
||
| There are multiple ways to add and install keyboards into your KeymanWeb installation. | ||
|
|
||
| ## Directly linking a local copy | ||
| ## Requesting from the Keyman cloud (CDN) | ||
|
|
||
| The most efficient way to utilize a keyboard is to obtain a local copy of it and place this copy in a static location on your website. Once this is done, it can be directly linked into KeymanWeb as follows. | ||
|
|
||
| ```c | ||
| keyman.addKeyboards({ | ||
| id:'us', // The keyboard's unique identification code. | ||
| name:'English', // The keyboard's user-readable name. | ||
| language:{ | ||
| id:'en', // A BCP 47 code uniquely identifying the language. | ||
| name:'English (US)' // The language's name. | ||
| }, | ||
| filename:'./us-1.0.js' // A valid path to the compiled *.js file representing the keyboard. | ||
| }); | ||
| ``` | ||
| The easiest way to utilize a keyboard is to request it from the Keyman cloud. | ||
|
|
||
| Custom fonts may also be utilized via the `language.font` property. For example: | ||
| ### Requested from the CDN by keyboard name | ||
|
|
||
| ```c | ||
| font:{ | ||
| family:'LaoWeb', | ||
| source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot'] | ||
| } | ||
| To obtain a specific keyboard by name or by keyboard name and language code as a pair, see the | ||
| following: | ||
|
|
||
| ```typescript | ||
| await keyman.addKeyboards('khmer_angkor','sil_euro_latin@sv','sil_euro_latin@no') | ||
| ``` | ||
|
|
||
| ## Requested from the CDN by language name | ||
| This will install three keyboards - the Khmer Angkor one for Khmer and two copies | ||
| of the EuroLatin keyboard - one for Swedish and one for Norwegian. | ||
|
|
||
| To obtain the default Keyman keyboard for a given language, call the following function. | ||
| ### Requested from the CDN by language name | ||
|
|
||
| ```c | ||
| keyman.addKeyboardsForLanguage('Dzongkha'); | ||
| To obtain the default Keyman keyboard for a given language, call the following function: | ||
|
|
||
| ```typescript | ||
| await keyman.addKeyboardsForLanguage('Dzongkha'); | ||
| ``` | ||
|
|
||
| This example would find the default keyboard for the Dzongkha language. This method will fail if the name doesn't perfectly match any language found in the CDN's repository. | ||
| This example would find the default keyboard for the Dzongkha language. This method will fail if | ||
| the name doesn't perfectly match any language found in the CDN's repository. | ||
|
|
||
| Alternatively, languages may be looked up via their BCP 47 language code as follows: | ||
|
|
||
| ```c | ||
| keyman.addKeyboards('@he') | ||
| ```typescript | ||
| await keyman.addKeyboards('@he') | ||
| ``` | ||
|
|
||
| The `@` prefix indicates the use of the BCP 47 language code, which in this case corresponds with Hebrew. | ||
| The `@` prefix indicates the use of the BCP 47 language code, which in this case corresponds with | ||
| Hebrew. | ||
|
|
||
| ## Requested from the CDN by keyboard name | ||
| To add all keyboards for a language at once, `$` can be appended to the language | ||
| name or language code: | ||
|
|
||
| To obtain a specific keyboard by name or by keyboard name and language code as a pair, see the following: | ||
| ```typescript | ||
| await keyman.addKeyboards('@fr$'); | ||
| // or | ||
| await keyman.addKeyboardsForLanguage('French$'); | ||
|
Comment on lines
+47
to
+49
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently not working - see #16018
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If not working, should we remove from the active docs and leave it to re-add when #16018 is resolved? |
||
| ``` | ||
|
|
||
| ```c | ||
| keyman.addKeyboards('french','sil_euro_latin@sv','sil_euro_latin@no') | ||
| ## Directly linking a local copy | ||
|
|
||
| The most efficient way to utilize a keyboard is to obtain a local copy of it and place this copy | ||
| in a static location on your website. Once this is done, it can be directly linked into KeymanWeb | ||
| as follows: | ||
|
|
||
| ```typescript | ||
| await keyman.addKeyboards({ | ||
| id: 'us', // The keyboard's unique identification code. | ||
| name: 'English', // The keyboard's user-readable name. | ||
| languages: { | ||
| id: 'en', // A BCP 47 code uniquely identifying the language. | ||
| name: 'English (US)' // The language's name. | ||
| }, | ||
| filename: './us.js' // A valid path to the compiled *.js file representing the keyboard. | ||
| }); | ||
| ``` | ||
|
|
||
| This will install three keyboards - one for French (named, quite simply, "French") and two copies of the EuroLatin keyboard - one for Swedish and one for Norwegian. | ||
| Custom fonts may also be utilized via the `languages.font` property. For example: | ||
|
|
||
| ```typescript | ||
| languages:{ | ||
| id:'lo', | ||
| name:'Lao', | ||
| font:{ | ||
| family:'LaoWeb', | ||
| source:['../font/saysettha_web.ttf','../font/saysettha_web.woff'] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| [Previous: What is a Keyboard?](what-is-a-keyboard) | [Next: Additional Examples](examples/) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,12 +4,12 @@ title: addKeyboards function | |
|
|
||
| ## Summary | ||
|
|
||
| Adds keyboards to KeymanWeb. | ||
| Adds keyboards to KeymanWeb. Note that this is an asynchronous operation. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```js | ||
| keyman.addKeyboards(spec[, spec...]) | ||
| await keyman.addKeyboards(spec[, spec...]) | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
@@ -54,6 +54,9 @@ The string format is one of the following: | |
| The keyboard catalogue is online at | ||
| [https://keyman.com/developer/keymanweb/keyboards](https://keyman.com/developer/keymanweb/keyboards). | ||
|
|
||
| If the BCP47 language code is suffixed with `$` (e.g. `@fr$`) and no specific keyboard is | ||
| requested, all keyboards for that language code will be loaded. | ||
|
Comment on lines
+57
to
+58
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this doesn't work, we shouldn't add it currently |
||
|
|
||
| ### Using an `object` | ||
|
|
||
| When keyboard spec is an object, then more parameters can be specified, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to change the order so that the simpler cases come first. This also matches the order of the parameter description in
addKeyboards.md.