Skip to main content

Class: OtaClient

Constructors

constructor

new OtaClient(distributionHash, config?)

Parameters

NameTypeDescription
distributionHashstringhash of released Crowdin project distribution
config?ClientConfigclient config

Defined in

index.ts:27

Strings Management Methods

getStringByKey

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

Returns translation string for language for given key

Parameters

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

Returns

Promise<any>

Defined in

index.ts:194


getStrings

getStrings(): Promise<LanguageStrings>

Returns translation strings from json-based files for all languages

Returns

Promise<LanguageStrings>

Defined in

index.ts:162


getStringsByLocale

getStringsByLocale(languageCode?): Promise<any>

Returns translation strings from json-based files for a given language

Parameters

NameTypeDescription
languageCode?stringLanguage Code

Returns

Promise<any>

Defined in

index.ts:180


Content Management Methods

getContent

getContent(): Promise<{ [languageCode: string]: string[]; }>

List distribution's files content

Returns

Promise<{ [languageCode: string]: string[]; }>

Defined in

index.ts:78


getFileTranslations

getFileTranslations(file): Promise<any>

Returns translations for a specific file (content)

Parameters

NameTypeDescription
filestringfile content path

Returns

Promise<any>

Defined in

index.ts:146


getLanguageContent

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

List distribution's files content for a specific language

Parameters

NameTypeDescription
languageCode?stringLanguage Code

Returns

Promise<string[]>

Defined in

index.ts:89


getLanguageTranslations

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

Returns translations for each file in the distribution for a given language

Parameters

NameTypeDescription
languageCode?stringLanguage Code

Returns

Promise<LanguageTranslations[]>

Defined in

index.ts:127


getTranslations

getTranslations(): Promise<Translations>

Returns all translations per each language code

Returns

Promise<Translations>

Defined in

index.ts:109


Helper Methods

clearStringsCache

clearStringsCache(): void

Clear the translation string cache

Returns

void

Defined in

index.ts:213


getCurrentLocale

getCurrentLocale(): undefined | string

Get the current locale

Returns

undefined | string

Defined in

index.ts:60


getHash

getHash(): string

Get the distribution hash

Returns

string

Defined in

index.ts:40


getManifestTimestamp

getManifestTimestamp(): Promise<number>

Get manifest timestamp of distribution

Returns

Promise<number>

Defined in

index.ts:69


listLanguages

listLanguages(): Promise<string[]>

List Crowdin project language codes

Returns

Promise<string[]>

Defined in

index.ts:100


setCurrentLocale

setCurrentLocale(languageCode?): void

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

NameTypeDescription
languageCode?stringLanguage Code

Returns

void

Defined in

index.ts:51