An open API service indexing awesome lists of open source software.

https://github.com/tabuckner/doggo-translator-ts

A typescript doggo translator based on DoggoTranslatorCore
https://github.com/tabuckner/doggo-translator-ts

Last synced: over 1 year ago
JSON representation

A typescript doggo translator based on DoggoTranslatorCore

Awesome Lists containing this project

README

          

# Doggo-Translator-TS
![Travis (.com)](https://img.shields.io/travis/com/tabuckner/doggo-translator-ts?style=plastic)
![Codecov](https://img.shields.io/codecov/c/github/tabuckner/doggo-translator-ts?style=plastic)
![GitHub language count](https://img.shields.io/github/languages/count/tabuckner/doggo-translator-ts?style=plastic)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/tabuckner/doggo-translator-ts?style=plastic)
![GitHub contributors](https://img.shields.io/github/contributors/tabuckner/doggo-translator-ts?style=plastic)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://paypal.me/tabuckner)

A TypeScript library for translating words to 'Doggo' speak!

### Usage
You can use the library defaults by creating an instance of the [DoggoTranslator](https://tabuckner.github.io/doggo-translator-ts/classes/doggotranslator.html) class, and using it's publicly available methods. [Read More](./examples/node/index.js)

Optionally you can pass in a [DoggoTranslatorConfig](https://tabuckner.github.io/doggo-translator-ts/interfaces/doggotranslatorconfig.html) object to configure the instance when created.

#### Basic Use Case
```javascript
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
```javascript
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](./examples/browser/index.html)

#### Node
To use in Node, check out the [this example](./examples/node/index.js)

### 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:

```typescript
import myLib from 'mylib'
```

Additionally, you can import the transpiled modules from `dist/lib` in case you have a modular library:

```typescript
import something from 'mylib/dist/lib/something'
```

### Public API
[TypeDoc Documentation](https://tabuckner.github.io/doggo-translator-ts/)

[translateSentence](https://tabuckner.github.io/doggo-translator-ts/classes/doggotranslator.html#translatesentence)

[getAllLanguageTokens](https://tabuckner.github.io/doggo-translator-ts/classes/doggotranslator.html#getalllanguagetokens)

[setLanguage](https://tabuckner.github.io/doggo-translator-ts/classes/doggotranslator.html#setlanguage)

## License
This application is released under the [MIT license](https://github.com/Gabbersaurus/DoggoTranslatorCore/blob/master/LICENSE).

## Inspired By
[DoggoTranslator (core) :dog:](https://gabbersaurus.github.io/DoggoTranslator/)