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
87 changes: 56 additions & 31 deletions developer/engine/web/20.0/guide/adding-keyboards.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,82 @@ 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.
The easiest way to utilize a keyboard is to request it from the Keyman cloud.

```js
await 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.
});
```
### Requested from the CDN by keyboard name

Custom fonts may also be utilized via the `language.font` property. For example:
To obtain a specific keyboard by name or by keyboard name and language code as a pair, see the
following:

```js
font:{
family:'LaoWeb',
source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']
}
```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.

### Requested from the CDN by language name

To obtain the default Keyman keyboard for a given language, call the following function.
To obtain the default Keyman keyboard for a given language, call the following function:

```js
```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:

```js
await 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
<!-- #16018
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$');
```
-->

```js
await 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/)
9 changes: 7 additions & 2 deletions developer/engine/web/20.0/reference/core/addKeyboards.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: addKeyboards function

## Summary

Adds keyboards to KeymanWeb.
Adds keyboards to KeymanWeb. Note that this is an asynchronous operation.

## Syntax

Expand Down Expand Up @@ -53,6 +53,11 @@ 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).

<!-- #16018
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.
-->

### Using an `object`

When keyboard spec is an object, then more parameters can be specified,
Expand Down Expand Up @@ -182,4 +187,4 @@ The `spec.languages.font` object contains the following members:

### Not passing any parameter

Not passing any parameter will obtain all Keyman keyboards from the CDN.
Not passing any parameter will obtain all Keyman keyboards from the CDN.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ title: addKeyboardsForLanguage function

## Summary

Add default or all keyboards for a given language to KeymanWeb.
Add default or all keyboards for a given language to KeymanWeb. Note that this is an asynchronous
operation.

## Syntax

Expand All @@ -30,6 +31,7 @@ The promise is an array containing the following:

* successfully registered keyboard objects which define some or all of these
[properties](../keyboard_properties)
* [ErrorStub](../keyboard_registration_errors) objects for keyboards that failed to register

## Description

Expand Down
Loading