Skip to main content

Class: OtaClient

Defined in: index.ts:8

Constructors​

new OtaClient()​

new OtaClient(distributionHash, config?): OtaClient

Defined in: index.ts:27

Parameters​

ParameterTypeDescription
distributionHashstringHash of released Crowdin project distribution
config?ClientConfigClient config

Returns​

OtaClient

Strings Management Methods​

getStrings()​

getStrings(): Promise<LanguageStrings>

Defined in: index.ts:173

Get all translation strings for all languages.

Returns​

Promise<LanguageStrings>

Translation strings from json-based files for all languages


getStringsByLocale()​

getStringsByLocale(languageCode?): Promise<any>

Defined in: index.ts:192

Get translation strings for a specific language.

Parameters​

ParameterTypeDescription
languageCode?stringLanguage Code

Returns​

Promise<any>

Translation strings from json-based files for a given language


getStringByKey()​

getStringByKey(key, languageCode?): Promise<any>

Defined in: index.ts:207

Get translation string for a specific key.

Parameters​

ParameterTypeDescription
keystring | string[]path to the translation string in json file
languageCode?stringLanguage Code

Returns​

Promise<any>

Translation string for language for given key

Content Management Methods​

getContent()​

getContent(): Promise<{}>

Defined in: index.ts:83

List distribution's files content.

Returns​

Promise<{}>

An object mapping Language Code to arrays of strings: {[languageCode: string]: string[]}


getLanguageContent()​

getLanguageContent(languageCode?): Promise<string[]>

Defined in: index.ts:94

List distribution's files content for a specific language.

Parameters​

ParameterTypeDescription
languageCode?stringLanguage Code

Returns​

Promise<string[]>


getTranslations()​

getTranslations(): Promise<Translations>

Defined in: index.ts:116

Get all translations for all languages.

Returns​

Promise<Translations>

All translations per each language code


getLanguageTranslations()​

getLanguageTranslations(languageCode?): Promise<LanguageTranslations[]>

Defined in: index.ts:135

Get translations for a specific language.

Parameters​

ParameterTypeDescription
languageCode?stringLanguage Code

Returns​

Promise<LanguageTranslations[]>

Translations for each file in the distribution for a given language (content)


getFileTranslations()​

getFileTranslations(file): Promise<any>

Defined in: index.ts:155

Get translations for a specific file.

Parameters​

ParameterTypeDescription
filestringfile content path

Returns​

Promise<any>

Translations for a specific file (content)

Helper Methods​

getHash()​

getHash(): string

Defined in: index.ts:43

Get the distribution hash.

Returns​

string


setCurrentLocale()​

setCurrentLocale(languageCode?): void

Defined in: index.ts:54

Define the global language for the client instance. Default language code to be used if language was not passed as an input argument of the method.

Parameters​

ParameterTypeDescription
languageCode?stringLanguage Code

Returns​

void


getCurrentLocale()​

getCurrentLocale(): undefined | string

Defined in: index.ts:63

Get the current locale of the client instance.

Returns​

undefined | string


getManifestTimestamp()​

getManifestTimestamp(): Promise<number>

Defined in: index.ts:72

Get distribution's manifest timestamp.

Returns​

Promise<number>


listLanguages()​

listLanguages(): Promise<string[]>

Defined in: index.ts:105

List Crowdin project language codes.

Returns​

Promise<string[]>


clearStringsCache()​

clearStringsCache(): void

Defined in: index.ts:226

Clear the translation strings cache.

Returns​

void