Project

zanata/project~ Project

The base class to deal with the operations on the client side to the Zanata.

Constructor

new Project(param)

Source:

All of responses from the server will be sent through the events.

Parameters:
Name Type Description
param Object

The options for Project. most of the properties will be stored into module:zanata/config~Config.

Properties
Name Type Attributes Description
url string

The URL to the Zanata server where you want to connect to.

username string <optional>

The username you want to connect to the Zanata with.

api-key string <optional>

The API key may be required to authorize for certain access on the Zanata.

Extends

  • EventEmitter

Methods

create(paramsopt)

Source:
See:

Create a project

Parameters:
Name Type Attributes Description
params object <optional>

the parameters to create a project. most properties will be stored into module:zanata/config~Config.

Properties
Name Type Attributes Description
project string

the project id

project-name string

the project name

project-type string

the default project type. it must be one of 'File', 'Gettext', 'Podir', 'Properties', 'Utf8Properties', 'Xliff', or 'Xml'

description string <optional>

the project description

Fires:

createVersion(projectId, versionId, params)

Source:
See:

Create a version in the project.

Parameters:
Name Type Description
projectId string

the project id

versionId string

the version id

params object

the parameters to create a version. most properties will be stored into module:zanata/config~Config.

Properties
Name Type Description
project-type string

the default project type. it must be one of 'File', 'Gettext', 'Podir', 'Properties', 'Utf8Properties', 'Xliff', or 'Xml'

Fires:

info(id, containLocales)

Source:

Obtain the project information from the Zanata.

Parameters:
Name Type Description
id string

the project id to obtain the information

containLocales boolean

true to contain the locale information in the result, otherwise will be suppressed.

Fires:

list(filteropt)

Source:

Obtain the projects and the information available on the Zanata

Parameters:
Name Type Attributes Default Description
filter Array.<string> <optional>
['id', 'name', 'status']

The properties you want to obtain from the project.

Fires:

pull(params)

Source:

Pull the documents from the Zanata

Parameters:
Name Type Description
params object

the parameters to pull the documents from the Zanata

Properties
Name Type Attributes Default Description
project string <optional>

the project id

version string <optional>

the project version id

pullType string <optional>
'both'

what the type of document you want to pull. 'source' for the source document, 'trans' for the translated document and 'both'.

locales string | Array.<string> <optional>

the locale names you want to pull. this only takes effect when pullType is 'both' or 'trans'.

potdir string <optional>
'./po'

the place where store the cache file for source document

podir string <optional>
'./po'

the place where store the cache file for translated document

verbose number <optional>
0

Show more progress messages verbosely.

force boolean <optional>
false

Transfer the document without the cache

skeletons boolean <optional>
false

Create skeleton entries even if the document isn't translated.

Fires:

pullSource(projectId, versionId, docId, paramsopt)

Source:

Pull the source document from the Zanata

Parameters:
Name Type Attributes Description
projectId string

the project id

versionId string

the version id

docId string

the document id

params object <optional>

the parameters to pull the source document

Properties
Name Type Attributes Default Description
potdir string <optional>
'./po'

the place where store the cache file

verbose number <optional>
false

Show more progress messages verbosely.

force boolean <optional>
false

Transfer the document without the cache

Fires:

pullSources(projectId, versionId, params)

Source:

Pull the source documents from the Zanata

Parameters:
Name Type Description
projectId string

the project id

versionId string

the project version id

params object

the parameters to pull the source documents from the Zanata

Properties
Name Type Attributes Default Description
potdir string <optional>
'./po'

the place where store the cache file

verbose number <optional>
false

Show more progress messages verbosely.

force boolean <optional>
false

Transfer the document without the cache

Fires:

pullTranslation(projectId, versionId, docId, locales, params)

Source:

Pull the translated document from the Zanata

Parameters:
Name Type Description
projectId string

the project id

versionId string

the project version id

docId string

the document id

locales Array.<string> | string

the locales you want to pull the translations

params object

the parameters to pull the translated document from the Zanata

Properties
Name Type Attributes Default Description
potdir string <optional>
'./po'

the place where store the cache file for source document

podir string <optional>
'./po'

the place where store the cache file for translated document

verbose number <optional>
0

Show more progress messages verbosely.

force boolean <optional>
false

Transfer the document without the cache

skeletons boolean <optional>
false

Create skeleton entries even if the document isn't translated.

Fires:

pullTranslations(projectId, versionId, locales, params)

Source:

Pull the translated documents from the Zanata

Parameters:
Name Type Description
projectId string

the project id

versionId string

the project version id

locales Array.<string> | string

the locales you want to pull the translations

params object

the parameters to pull the translated document from the Zanata

Properties
Name Type Attributes Default Description
potdir string <optional>
'./po'

the place where store the cache file for source document

podir string <optional>
'./po'

the place where store the cache file for translated document

verbose number <optional>
0

Show more progress messages verbosely.

force boolean <optional>
false

Transfer the document without the cache

skeletons boolean <optional>
false

Create skeleton entries even if the document isn't translated.

Fires:

push(paramsopt)

Source:

Push the documents to the Zanata

Parameters:
Name Type Attributes Description
params object <optional>

the parameters to push the documents

Properties
Name Type Attributes Default Description
pushType string <optional>
'both'

what the type of the document you want to push. 'source' for the source documents, 'trans' for the translated documents, and 'both'.

project string <optional>

the project id

version string <optional>

the project version id

locales string <optional>

the locale names you want to push

project-type string <optional>

the project type

potdir string <optional>
'./po'

the place where read POT files

podir string <optional>
'./po'

the place where read PO files

verbose number <optional>
0

Show more progress messages verbosely.

copyTrans boolean <optional>
false

Copy the latest translations from equivalent messages/documents in the Zanata if true

dryrun boolean <optional>
false

Do not send the data to the Zanata if true.

Fires:

pushSource(projectId, versionId, file, paramsopt)

Source:

Push the source document to the Zanata

Parameters:
Name Type Attributes Description
projectId string

the project id

versionId string

the project version id

file string

the filename which you want to push as the source document

params object <optional>

the parameters to push the source document

Properties
Name Type Attributes Default Description
verbose number <optional>
0

Show more progress messages verbosely.

Fires:

pushSources(projectId, versionId, paramsopt)

Source:

Push the source documents to the Zanata

Parameters:
Name Type Attributes Description
projectId string

the project id

versionId string

the project version id

params object <optional>

the parameters to push the source document

Properties
Name Type Attributes Default Description
verbose number <optional>
0

Show more progress messages verbosely.

potdir string <optional>
'./po'

the place where read POT files

dryrun boolean <optional>
false

Do not send the data to the Zanata if true.

Fires:

pushTranslation(projectId, versionId, docId, locale, file, paramsopt)

Source:

Push the translated document to the Zanata

Parameters:
Name Type Attributes Description
projectId string

the project id

versionId string

the project version id

docId string

the document id

locale string

the locale name pushing the document

file string

the filename which you want to push as the translated document

params object <optional>

the parameters to push the translated document

Properties
Name Type Attributes Default Description
verbose number <optional>
0

Show more progress messages verbosely.

copyTrans boolean <optional>
false

Copy the latest translations from equivalent messages/documents in the Zanata if true

Fires:

pushTranslations(projectId, versionId, locales, paramsopt)

Source:

Push the translated documents to the Zanata

Parameters:
Name Type Attributes Description
projectId string

the project id

versionId string

the project version id

locales Array.<string>

the locale name pushing the documents

params object <optional>

the parameters to push the translated documents

Properties
Name Type Attributes Default Description
project-type string <optional>

the project type

podir string <optional>
'./po'

the place where read PO files

potdir string <optional>
'./po'

the place for POT files

verbose number <optional>
0

Show more progress messages verbosely.

copyTrans boolean <optional>
false

Copy the latest translations from equivalent messages/documents in the Zanata if true

dryrun boolean <optional>
false

Do not send the data to the Zanata if true.

Fires:

stats(projectId, versionId, docIdopt, paramsopt)

Source:

Obtain document statistics from the Zanata

Parameters:
Name Type Attributes Description
projectId string

the project id

versionId string

the project version id

docId string <optional>

the document id

params object <optional>

the parameters to obtain the document statistics

Properties
Name Type Attributes Default Description
locales Array.<string> | string <optional>

the locale names you want to obtain the statistics

detail boolean <optional>
false

whether include the detailed statistics

word boolean <optional>
false

whether include the word-level statistics

Fires:

versionInfo(projectId, versionId, containLocales)

Source:

Obtain the information about the version for the project

Parameters:
Name Type Description
projectId string

the project id

versionId string

the version id

containLocales boolean

true to contain the locale information in the result, otherwise will be suppressed.

Fires:

Events

data_create

Source:

data event from create method. this contains the result string.

Type:
  • string

data_info

Source:
See:
Properties:
Name Type Attributes Description
id string

the project id

defaultType string

the default project type

name string

the project name

status string

the project status

description string

the project description

sourceViewURL string

the source view URL for the project

sourceCheckoutURL string

the source URL to check out

versions Array.<object>

the version-related information

Properties
Name Type Description
id string

the version id

defaultType string

the project version type

status string

the status

locales Array.<object> <optional>

the locale name available in this project

Properties
Name Type Attributes Description
localeId object

the LocaleId object

Properties
Name Type Description
id string

BCP-47 language tag

displayName string <optional>

the display name of the locale

alias string <optional>

the alias name

nativeName string <optional>
enabled boolean
enabledByDefault boolean
pluralForms string <optional>

data event from info method.

Type:
  • object

data_list

Source:
See:
Properties:
Name Type Description
id string

the project id

defaultType string

the default project type

name string

the project name

status string

the project status

description string

the project description

sourceViewURL string

the source view URL for the project

sourceCheckoutURL string

the source URL to check out

data event from list method

Type:
  • Array.<object>

data_pull

Source:
Properties:
Name Type Attributes Description
name string

the document id

type string

the document type. 'pot' for the source document and 'po' for the translation

data string

the contents for POT file

locale string <optional>

the locale name for document. this is only available when pulling translations

data event from pull methods. this is emitted when any data is received from the Zanata on pulling.

Type:
  • object

data_push

Source:

data event from push methods. this event is emitted after pushing data to the Zanata. the passed data contains the filename that pushed to the Zanata.

Type:
  • string

data_stats

Source:
See:
Properties:
Name Type Description
id string
stats Array.<object>
Properties
Name Type Description
total number
untranslated number
needReview number
translated number
approved number
rejected number
fuzzy number
unit string
locale string
lastTranslated string
translatedOnly number
detailedStats Array.<object>

data event from stats method

Type:
  • object

data_version_info

Source:
See:
Properties:
Name Type Attributes Description
id string

the version id

status string

the status

projectType string

the project type

locales Array.<object> <optional>

the locale name available in this project

Properties
Name Type Attributes Description
localeId object

the LocaleId object

Properties
Name Type Description
id string

BCP-47 language tag

displayName string <optional>

the display name of the locale

alias string <optional>

the alias name

nativeName string <optional>
enabled boolean
enabledByDefault boolean
pluralForms string <optional>

data event from versionInfo method.

Type:
  • object

end_pull

Source:
Properties:
Name Type Attributes Description
name string

the document id

type string

the document type. 'pot' for the source document and 'po' for the translation

pulled boolean

whether the document was actually pulled from the Zanata or the cache due to no changes since the last pull.

locale string <optional>

the locale name for document. this is only available when pulling translations

end event for pull methods. this is emitted when all of pulling is finished.

Type:
  • Array.<object>

end_push

Source:
Properties:
Name Type Attributes Description
docId string

the document id

type string

the document type pushed. 'pot' for the source document and 'po' for the translated document

file string

the finename pushed to the Zanata.

locale string <optional>

the locale name pushed to the Zanata. this property is only available when pushing the translated document

end event from push methods. this event is emitted when all of pushing is finished.

Type:
  • Array.<object>

fail

Source:

fail event

Type:
  • Error

warning

Source:

warning event from pull/push methods. this contains the warning messages where happened during processing and not that important more than stopping.

Type:
  • string