Fetch

Monster/I18n/Providers. Fetch

The fetch provider retrieves a JSON file from the given URL and returns a translation object.

You can call the method via the monster namespace new Monster.I18n.Provider().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/i18n/providers/fetch.js';
console.log(new Monster.I18n.Providers.Fetch())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {Fetch} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/i18n/providers/fetch.js';
console.log(new Fetch())
</script>

Constructor

# new Fetch(url, options)

As options the key fetch can be passed. This config object is passed to the fetch method as init.

Parameters:
Name Type Description
url string | URL
options object
Since:
  • 1.13.0

Members

# defaults

Defaults

Methods

# getTranslations(locale) → {Promise}

Parameters:
Name Type Description
locale Locale | string
Returns:
Type
Promise