Skip to main content

Configuration

There is a way to customize the client to your needs. You can pass a configuration object as a second (optional) argument in the constructor.

import otaClient, { ClientConfig } from '@crowdin/ota-client';

const config: ClientConfig = {
httpClient: customHttpClient,
disableManifestCache: false,
languageCode: 'uk',
disableStringsCache: false,
disableJsonDeepMerge: true
};

const hash = '{distribution_hash}';

const client = new otaClient(hash, config);

Config Options

hash

Distribution Hash. See the Content Delivery article for more details.

httpClient

Custom HTTP client.

Default: Axios HTTP client

languageCode

Default language code to be used if language was not passed as an input argument of the method (also possible via setCurrentLocale method)

tip

Visit the Language Codes page to see the list of supported language codes.

disableManifestCache

Disable distribution manifest file caching, which results in an additional request for each client method.

Default: false

caution

Disabling the manifest cache may result in additional charges.

disableStringsCache

Disable caching of translation strings which is used for JSON-based client methods.

Default: false

caution

Disabling the strings cache may result in additional charges.

disableJsonDeepMerge

Disable deep merge of json-based files for string-based methods and use shallow merge.

Default: false

Axios error

There might be an issue with axios dependency when using webpack 5 or babel build tools (e.g. React Scripts 5+ or Expo).

In case if you got following error:

ERROR
Cannot read properties of undefined (reading 'create')
TypeError: Cannot read properties of undefined (reading 'create')

You will have to manually install axios 1.6.0

npm i axios

And pass it in OTA Client config

import otaClient from '@crowdin/ota-client';

const client = new otaClient(hash, {
httpClient: {
get: async (url) => {
const res = await axios.get(url);
return res.data;
}
}
});

Further reading