0.2.11 • Published 1 year ago

@volley/solid-localization v0.2.11

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
1 year ago

@volley/solid-localization

This library provides easy localization support for @volley/solid & @volley/solid-gev voice-skills.

Installation

> npm i @volley/solid-localization

@volley/solid-gev Skills

If you're using @volley/solid-gev follow these steps.

Configuration

Install the supplied GEV localization plugin:

import { plugin as localizationPlugin } from "@volley/localization";

// in your GEV plugin setup
[
  // ...
  localizationPlugin,
  // ...
];

Pass the session container to installCopy() and bind your ILocaleProvider:

import {
  AlexaLocaleLens,
  installCopy,
  tokens as localeTokens,
  ILocaleProvider,
} from "@volley/solid-localization";

// in your session startup
installCopy(container);

container // allow AlexaLocaleLens to resolve the Engine
  .bind(localeTokens.Engine)
  .to($);

container.bind(ILocaleProvider).to(AlexaLocaleLens);

Usage

Define a copy service:

import { injectable } from "inversify";
import { BaseCopyService } from "@volley/solid-localization";

@injectable()
class IntroCopy extends BaseCopyService<IntroCopy> {
  ["en-US"] = "Welcome to the Alexa Skills Kit, you can say hello!" as const;
  ["de-DE"] =
    "Willkommen bei der Alexa Fähigkeiten Kit, du kannst Hallo sagen!" as const;
}

Use the copy service:

import { Copy, copy } from "@volley/solid-localization";

class IntroScene {
  @copy(IntroCopy)
  protected introCopy!: Copy<IntroCopy>;

  say(copy: string) {
    console.log(copy);
  }

  async enter() {
    this.say(this.introCopy);
  }
}

this.introCopy will automatically resolve to the correct localization for the user's locale.

0.2.11

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago