@tabuckner/doggo-translator-ts
v0.0.3
Published
A typescript doggo translator based on DoggoTranslatorCore
Downloads
15
Maintainers
Readme
Doggo-Translator-TS
A TypeScript library for translating words to 'Doggo' speak!
Usage
You can use the library defaults by creating an instance of the DoggoTranslator class, and using it's publicly available methods. Read More
Optionally you can pass in a DoggoTranslatorConfig object to configure the instance when created.
Basic Use Case
const library = require('../dist/doggo-translator-ts.umd');
const DoggoTranslator = library.DoggoTranslator;
const myTranslator = new DoggoTranslator();
console.warn(myTranslator.translateSentence('Testing this, bark!'))
console.warn(myTranslator.translateSentence('Hello friend! I hope you have a great day!'))
User Defined Translations
const library = require('../dist/doggo-translator-ts.umd');
const DoggoTranslator = library.DoggoTranslator;
const myTranslations ={
words: {
hey: 'hi',
friend: 'frenn',
run: 'floop'
},
suffixes: {
ing: 'in'
}
}
const myTranslator = new DoggoTranslator({ userDefinedTranslations: myTranslations });
const text = 'Hey Friend! Do you want to go run around? I love running!';
const translated = myTranslator.translateSentence(text)
console.warn(translated); // Hi frenn! Do you want to go floop around? I love runnin.
Browser
To use in Browser, check out the this example
Node
To use in Node, check out the this example
Features
User Supplied Translation Definitions
You can pass a TranslationMapInterface
compliant object to the DoggoTranslatorConfig
when instantiating to supply new translations on the fly.
Word Swaps
Entire words can be swapped, as expected.
Suffix Swaps
Optionally you can supply 'suffixes' to be swapped at the end of words.
Importing library
You can import the generated bundle to use the whole library generated by this starter:
import myLib from 'mylib'
Additionally, you can import the transpiled modules from dist/lib
in case you have a modular library:
import something from 'mylib/dist/lib/something'
Public API
License
This application is released under the MIT license.