crowdin

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 15 Imported by: 2

README

go-crowdinv2

API calls for Crowdin API V2: https://support.crowdin.com/enterprise/api/

Inspired by https://github.com/medisafe/go-crowdin

Implement Crowdin API V2, proxy connection, Some high level methods.

Documentation

Index

Constants

View Source
const API_CROWDINDOTCOM = "https://crowdin.com/api/v2/" // url for crowdin.com (non Enterprise version)
View Source
const DEFAULT_CONNEXION_TO = 5 // seconds
View Source
const DEFAULT_RW_TO = 40 // seconds
View Source
const MAX_RESULTS = 1000000 // 1M lines maximum for any api responses
View Source
const MAX_RES_PER_PAGE = 500 // Max nber of lines per page returned by API calls.

Variables

This section is empty.

Functions

func SetDefaultTimeouts

func SetDefaultTimeouts(cnctTO, rwTO time.Duration)

Set connection and read/write timeouts for the subsequent new connections

Types

type APIError

type APIError struct {
	What string
}

APIError holds data of errors returned from the API.

func (APIError) Error

func (e APIError) Error() string

type AddApprovalOptions

type AddApprovalOptions struct {
	TranslationID int `json:"translationId,omitempty"`
}

Add Approval API call

type AddStorageOptions

type AddStorageOptions struct {
	FileName string `json:"filename"` // Filename and path of hte file to upload to storage
}

AddStorageOptions are options for AddStorage api call

type BuildDirectoryTranslationOptions

type BuildDirectoryTranslationOptions struct {
	TargetLanguageIds               []string `json:"targetLanguageIds,omitempty"`
	SkipUntranslatedStrings         bool     `json:"skipUntranslatedStrings,omitempty"`
	SkipUntranslatedFiles           bool     `json:"skipUntranslatedFiles,omitempty"`
	ExportApprovedOnly              bool     `json:"exportApprovedOnly,omitempty"`          // crowdin.com specific
	ExportWithMinApprovalsCount     int      `json:"exportWithMinApprovalsCount,omitempty"` // Enterprise specific
	PreserveFolderHierarchy         bool     `json:"preserveFolderHierarchy,omitempty"`
	ExportStringsThatPassedWorkflow bool     `json:"exportStringsThatPassedWorkflow,omitempty"`
}

BuildDirectoryTranslationOptions are options for BuildDirectoryTranslation api call

type BuildFileTranslationOptions

type BuildFileTranslationOptions struct {
	TargetLanguageID                string `json:"targetLanguageId"`
	ExportAsXliff                   bool   `json:"exportAsXliff"`
	SkipUntranslatedStrings         bool   `json:"skipUntranslatedStrings"`
	SkipUntranslatedFiles           bool   `json:"skipUntranslatedFiles"`
	ExportApprovedOnly              bool   `json:"exportApprovedOnly,omitempty"`          // crowdin.com specific
	ExportWithMinApprovalsCount     int    `json:"exportWithMinApprovalsCount,omitempty"` // Enterprise specific
	ExportStringsThatPassedWorkflow bool   `json:"exportStringsThatPassedWorkflow,omitempty"`
}

BuildDirectoryFileOptions are options for BuildFileTranslation api call

type BuildProjectTranslationOptions

type BuildProjectTranslationOptions struct {
	BranchId int `json:"branchId,omitempty"` // Branch Identifier. - optional
	// Specify target languages for build.
	// Leave this field empty to build all target languages
	Languages                       []string `json:"targetLanguageIds,omitempty"`
	SkipUntranslatedStrings         bool     `json:"skipUntranslatedStrings,omitempty"`
	SkipUntranslatedFiles           bool     `json:"skipUntranslatedFiles,omitempty"`
	ExportApprovedOnly              bool     `json:"exportApprovedOnly,omitempty"`          // crowdin.com specific
	ExportWithMinApprovalsCount     int      `json:"exportWithMinApprovalsCount,omitempty"` // Enterprise specific
	ExportStringsThatPassedWorkflow bool     `json:"exportStringsThatPassedWorkflow,omitempty"`
}

BuildProjectTranslationOptions are options for BuildProjectTranslation api call

type BuildTranslationAllLgOptions

type BuildTranslationAllLgOptions struct {
	BuildTO                     time.Duration
	TranslatedOnly              bool
	MinApprovalSteps            int
	FullyTranslatedFilesOnly    bool
	ExportStringsThatPassedWkfl bool
	FolderName                  string // Optional - if not empty and valid, build a folder
}

type CheckProjectBuildStatusOptions

type CheckProjectBuildStatusOptions struct {
	// Project Identifier.
	// ProjectId int
	BuildId int
}

GetProjectBuildProgressOptions are options for Check Project Build Status api call

type Crowdin

type Crowdin struct {
	// contains filtered or unexported fields
}

Crowdin API V2 wrapper

func New

func New(token string, projectId int, apiurl string, proxy string) (*Crowdin, error)

New - a create new instance of Crowdin API V2.

func (*Crowdin) AddApproval

func (crowdin *Crowdin) AddApproval(options *AddApprovalOptions) (*ResponseAddApproval, error)

AddApproval - Add Approval API call. Set proofread approval to a translation. {protocol}://{host}/api/v2/storages

func (*Crowdin) AddStorage

func (crowdin *Crowdin) AddStorage(options *AddStorageOptions) (*ResponseAddStorage, error)

AddStorage - Add storage API call. Upload a file to a storage space. {protocol}://{host}/api/v2/storages

func (*Crowdin) BuildAllLg

func (crowdin *Crowdin) BuildAllLg(buildTO time.Duration, translatedOnly bool, minApprovalSteps int, fullyTranslatedFilesOnly bool) (buildId int, err error)

BuildAllLg - Build a project for all languages. Kept to maintain compatibility with older versions. Options to export:

  • translated strings only Y/N
  • approved strings only integer Enterprise: min nb of approval steps required to export a string crowdin.com: 0 means approval not required, diff from 0: approval required
  • fully translated files only Y/N "translated strings only" and fully "translated files only" are mutually exclusive.

Update buildProgress

func (*Crowdin) BuildDirectoryTranslation

func (crowdin *Crowdin) BuildDirectoryTranslation(directoryId int, options *BuildDirectoryTranslationOptions) (*ResponseBuildDirectoryTranslation, error)

BuildDirectoryTranslation - Build a directory {protocol}://{host}/api/v2/projects/{projectId}/translations/builds/directories/{directoryId}

func (*Crowdin) BuildFileTranslation

func (crowdin *Crowdin) BuildFileTranslation(fileId int, options *BuildFileTranslationOptions) (*ResponseBuildFileTranslation, error)

BuildFileTranslation - Build a file {host}/api/v2/projects/{projectId}/translations/builds/files/{fileId}

func (*Crowdin) BuildProjectTranslation

func (crowdin *Crowdin) BuildProjectTranslation(options *BuildProjectTranslationOptions) (*ResponseBuildProjectTranslation, error)

BuildProjectTranslation - Build a project {protocol}://{host}/api/v2/projects/{ProjectId}/translations/builds

func (*Crowdin) BuildTranslationAllLg

func (crowdin *Crowdin) BuildTranslationAllLg(opt BuildTranslationAllLgOptions) (buildId int, err error)

func (*Crowdin) CheckProjectBuildStatus

func (crowdin *Crowdin) CheckProjectBuildStatus(options *CheckProjectBuildStatusOptions) (*ResponseCheckProjectBuildStatus, error)

CheckProjectBuildStatus - Check Project Build Status api call {protocol}://{host}/api/v2/projects/{projectId}/translations/builds/{buildId}

func (*Crowdin) Close

func (crowdin *Crowdin) Close()

func (*Crowdin) DeleteStorage

func (crowdin *Crowdin) DeleteStorage(options *DeleteStorageOptions) error

deleteStorage - Delete a storage {protocol}://{host}/api/v2/storages/{storageId}

func (*Crowdin) DownloadBuild

func (crowdin *Crowdin) DownloadBuild(outputFileNamePath string, buildId int) (err error)

Download a build of the current project

outputFileNamePath  required
projectId           required if projectName is not provided
buildId             optional

limitation: total number of project directories needs to be 500 max

func (*Crowdin) DownloadFile

func (crowdin *Crowdin) DownloadFile(url string, filepath string) error

DownloadFile will download a url and store it in local filepath. No autorization token required here for this operation. Writes to the destination file as it downloads it, without loading the entire file into memory.

func (*Crowdin) DownloadProjectTranslations

func (crowdin *Crowdin) DownloadProjectTranslations(options *DownloadProjectTranslationsOptions) (*ResponseDownloadProjectTranslations, error)

DownloadProjectTranslations - Download Project Translations api call {protocol}://{host}/api/v2/projects/{projectId}/translations/builds/{buildId}/download

func (*Crowdin) EditStrings

func (crowdin *Crowdin) EditStrings(options *EditStringsOptions, stringId int) (*ResponseEditStrings, error)

func (*Crowdin) GetBuildId

func (crowdin *Crowdin) GetBuildId() (buildId int, err error)

Lookup buildId for current project

func (*Crowdin) GetDebugWriter

func (crowdin *Crowdin) GetDebugWriter() (logWriter io.Writer)

GetDebugWriter - get writer

func (*Crowdin) GetFileProgress

func (crowdin *Crowdin) GetFileProgress(options *GetFileProgressOptions) (*ResponseGetFileProgress, error)

GetFileProgress() - Get file progress info {protocol}://{host}/api/v2/projects/{projectId}/files/{fileId}/languages/progress

func (*Crowdin) GetFileRevision

func (crowdin *Crowdin) GetFileRevision(fileId int, revId int) (*ResponseGetFileRevision, error)

GetFileRevision - List a specific revision details for a file in current project {protocol}://{host}/api/v2/projects/{projectId}/files/{fileId}/revisions/{revisionId}

func (*Crowdin) GetPercentBuildProgress

func (crowdin *Crowdin) GetPercentBuildProgress() int

Read current build progress status from Crowdin structure That value is updated when a build is running and GetBuildProgress() polled.

func (*Crowdin) GetProject

func (crowdin *Crowdin) GetProject() (*ResponseGetProject, error)

GetProject - Read project details {protocol}://{host}/api/v2/projects/{projectId}

func (*Crowdin) GetProjectId

func (crowdin *Crowdin) GetProjectId(projectName string) (projectId int, err error)

Lookup projectId

func (*Crowdin) GetShortLangFileProgress

func (crowdin *Crowdin) GetShortLangFileProgress(fileId int, langId string) (translationProgress int, approvalProgress int, err error)

GetShortLangFileProgress() - Get a simple file completion info for a specific language

Returns a percentage of completion for both translation and approval (0 if error).

func (*Crowdin) GetStepsApprovTransId

func (crowdin *Crowdin) GetStepsApprovTransId() (listTrans map[int][]int, err error)

Get steps of all approved transactions from a given project.

Returns a map of all ADMIN approved transactions along with their approval steps.

func (*Crowdin) GetStorage

func (crowdin *Crowdin) GetStorage(options *GetStorageOptions) (*ResponseGetStorage, error)

GetStorage - Read the file name associated to a storageId {protocol}://{host}/api/v2/storages/{storageId}

func (*Crowdin) GetStringIDs

func (crowdin *Crowdin) GetStringIDs(fileName string, filter string, filterType string) (list []int, err error)

Obtain a list of string Ids for a given file of the current project. Use a filter on "identifier" "text" or "context" Parameters:

  • provide path/filename
  • a filter string (empty mean "all")
  • filter on "identifier" "text" or "context"

Returns:

  • string IDs in a slice of ints if results found
  • err (nil if no error)

func (*Crowdin) GetTimeouts

func (crowdin *Crowdin) GetTimeouts() (connectionTO, rwTO time.Duration)

Get connection and read/write timeouts

func (*Crowdin) GetTranslation

func (crowdin *Crowdin) GetTranslation(options *GetTranslationOptions) (*ResponseGetTranslation, error)

GetTranslation - Get translation details {protocol}://{host}/api/v2/projects/{projectId}/translations/{translationId}

func (*Crowdin) ListAllDirectories

func (crowdin *Crowdin) ListAllDirectories(options *ListDirectoriesOptions) (*ResponseListDirectories, error)

ListAllDirectories - Helper function: list all directories in a given project (all pages) Ignore offset and limit in options.

func (*Crowdin) ListDirectories

func (crowdin *Crowdin) ListDirectories(options *ListDirectoriesOptions) (*ResponseListDirectories, error)

ListDirectories - List directories in a given project {protocol}://{host}/api/v2/projects/{projectId}/files

func (*Crowdin) ListFileRevisions

func (crowdin *Crowdin) ListFileRevisions(options *ListFileRevisionsOptions, fileId int) (*ResponseListFileRevisions, error)

ListFileRevisions - List all revisions for a file in current project {protocol}://{host}/api/v2/projects/{projectId}/files/{fileId}/revisions

func (*Crowdin) ListFiles

func (crowdin *Crowdin) ListFiles(options *ListFilesOptions) (*ResponseListFiles, error)

ListFiles - List files in a given project {protocol}://{host}/api/v2/projects/{projectId}/files

func (*Crowdin) ListProjectBuilds

func (crowdin *Crowdin) ListProjectBuilds(options *ListProjectBuildsOptions) (*ResponseListProjectBuilds, error)

ListProjectBuilds - List Project Builds API call. List the project builds {protocol}://{host}/api/v2/projects/{projectId}/translations/builds

func (*Crowdin) ListProjects

func (crowdin *Crowdin) ListProjects(options *ListProjectsOptions) (*ResponseListProjects, error)

ListProjects - List projects API call. List the projects and their respective details (incl.Id.) {protocol}://{host}/api/v2/projects

func (*Crowdin) ListStorages

func (crowdin *Crowdin) ListStorages(options *ListStoragesOptions) (*ResponseListStorages, error)

ListStorages - List existing storages {protocol}://{host}/api/v2/storages

func (*Crowdin) ListStrings

func (crowdin *Crowdin) ListStrings(options *ListStringsOptions) (*ResponseListStrings, error)

ListStrings - List Source Strings {protocol}://{host}/api/v2/projects/{projectId}/strings

func (*Crowdin) ListTranslationApprovals

func (crowdin *Crowdin) ListTranslationApprovals(options *ListTranslationApprovalsOptions) (*ResponseListTranslationApprovals, error)

ListTranslationApprovals - List translation approvals of a file, a string or a translation {protocol}://{host}/api/v2/projects/{projectId}/approvals

func (*Crowdin) ListWorkflowsSteps

func (crowdin *Crowdin) ListWorkflowsSteps(options *ListWorkflowsStepsOptions) (*ResponseListWorkflowsSteps, error)

ListWorkflowsSteps - List workflow steps {protocol}://{host}/api/v2/projects/{projectId}/workflow-steps

func (*Crowdin) LookupDirId

func (crowdin *Crowdin) LookupDirId(CrowdinDirName string) (id int, name string, err error)

Lookup directoryId in current project

   CrowdinDirName required - full Crowdin path to directory.
		Returns Id and crowdin dir name

func (*Crowdin) LookupFileId

func (crowdin *Crowdin) LookupFileId(CrowdinFileName string) (id int, name string, err error)

Lookup fileId in current project

   CrowdinFileName required - full Crowdin path to file.
		Returns Id and crowdin file name

func (*Crowdin) PopTimeouts

func (crowdin *Crowdin) PopTimeouts()

Restore previously saved timeout values

func (*Crowdin) PushTimeouts

func (crowdin *Crowdin) PushTimeouts()

Save current timeout values

func (*Crowdin) ResetTimeoutsToDefault

func (crowdin *Crowdin) ResetTimeoutsToDefault()

Reset communication timeouts to their default values

func (*Crowdin) SetDebug

func (crowdin *Crowdin) SetDebug(debug bool, logWriter io.Writer)

SetDebug - traces errors if it's set to true.

func (*Crowdin) SetTimeouts

func (crowdin *Crowdin) SetTimeouts(connectionTO, rwTO time.Duration)

Set connection and read/write timeouts

0 means doesn't change value

func (*Crowdin) Update

func (crowdin *Crowdin) Update(CrowdinFileName string, LocalFileName string, updateOption string) (fileId int, revId int, err error)

Update a file of the current project

   LocalFileName  required
   CrowdinFileName required
   updateOption required needs to be either: clear_translations_and_approvals, keep_translations or keep_translations_and_approvals
		Returns file Id and rev

func (*Crowdin) UpdateFile

func (crowdin *Crowdin) UpdateFile(fileId int, options *UpdateFileOptions) (*ResponseUpdateFile, error)

UpdateFile - Update a specific file {protocol}://{host}/api/v2/projects/{projectId}/files/{fileId} Default update mode is explicitely clear_translations_and_approvals

func (*Crowdin) UploadTranslationFile

func (crowdin *Crowdin) UploadTranslationFile(params T_UploadTranslationFileParams) (fileId int, err error)

Upload a translation file Params:

  • File containing the translations to upload
  • File in Crowdin where the translations will end up
  • Language ID as per Crowdin spec and defined as target in the project
  • Defines whether to add translation if it's the same as the source string
  • Mark uploaded translations as approved
  • Allow translations upload to hidden source strings
  • in seconds. The upload operation can take several minutes. 0 means no change. The original TO will be restored after operation finishes (ok or not) Returns the source fileId (0 if error) and err != nil if error

func (*Crowdin) UploadTranslations

func (crowdin *Crowdin) UploadTranslations(LanguageId string, options *UploadTranslationsOptions) (*ResponseUploadTranslations, error)

UploadTranslations() - Upload translations into a file API call {protocol}://{host}/api/v2/projects/{projectId}/translations/{languageId}

type DeleteStorageOptions

type DeleteStorageOptions struct {
	StorageId int `json:"storageid"`
}

DelStorageOptions are options for DelStorage api call

type DownloadProjectTranslationsOptions

type DownloadProjectTranslationsOptions struct {
	// Project Identifier.
	// ProjectId int
	// Build Identifier.
	BuildId int
}

DownloadProjectTranslationsOptions are options for DownloadProjectTranslations api call

type EditStringsOptions

type EditStringsOptions []struct {
	Value interface{} `json:"value"` // type depends on path value
	Op    string      `json:"op"`
	Path  string      `json:"path"`
}

EditString - Edit a source string API call

type GetFileProgressOptions

type GetFileProgressOptions struct {
	FileId int
	Limit  int
	Offset int
}

GetFileProgress - options for Language Progress API call

type GetStorageOptions

type GetStorageOptions struct {
	StorageId int
}

GetStorageOptions are options for GetStorage api call

type GetTranslationOptions

type GetTranslationOptions struct {
	TranslationID           int `json:"translationID,omitempty"`
	DenormalizePlaceholders int `json:"denormalizePlaceholders, omitempty"`
}

List workflow steps API call

type ListDirectoriesOptions

type ListDirectoriesOptions struct {
	BranchId    int
	DirectoryId int
	Recursion   int
	Limit       int // Maximum number of items to retrieve (25 default, max 500) - optional
	Offset      int // Offset in collection - optional
}

ListDirectoriesOptions are options for ListDirectories api call

type ListFileRevisionsOptions

type ListFileRevisionsOptions struct {
	Limit  int // Maximum number of items to retrieve (25 default, max 500) - optional
	Offset int // Offset in collection - optional
}

ListFilesOptions are options for ListFileRevisions api call

type ListFilesOptions

type ListFilesOptions struct {
	BranchId    int `json:"branchId,omitempty"`
	DirectoryId int `json:"directoryId,omitempty"`
	Recursion   int `json:"recursion,omitempty"`
	Limit       int `json:"limit,omitempty"`  // Maximum number of items to retrieve (25 default, max 500) - optional
	Offset      int `json:"offset,omitempty"` // Offset in collection - optional
}

ListFilesOptions are options for ListFiles api call

type ListProjectBuildsOptions

type ListProjectBuildsOptions struct {
	// ProjectId 			int
	// Body struct {
	BranchId int
	Limit    int
	Offset   int
}

ListProjectBuilds - List Project Build API call

type ListProjectsOptions

type ListProjectsOptions struct {
	GroupId          int
	HasManagerAccess int
	Limit            int
	Offset           int
}

ListProjects - List Projects API call

type ListStoragesOptions

type ListStoragesOptions struct {
	Limit  int // Maximum number of items to retrieve (25 default, max 500) - optional
	Offset int // Offset in collection - optional
}

ListStoragesOptions are options for ListStorages api call

type ListStringsOptions

type ListStringsOptions struct {
	FileId                  int
	DenormalizePlaceholders int
	LabelIds                string
	Filter                  string
	Scope                   string
	Limit                   int // Maximum number of items to retrieve (25 default, max 500) - optional
	Offset                  int // Offset in collection - optional
}

ListStringsOptions are options for ListStrings api call

type ListTranslationApprovalsOptions

type ListTranslationApprovalsOptions struct {
	TranslationID int    `json:"translationId,omitempty"`
	FileID        int    `json:"fileId,omitempty"`
	StringID      int    `json:"stringId,omitempty"`
	LanguageID    string `json:"languageId,omitempty"`
	Limit         int    `json:"limit,omitempty"`  // Maximum number of items to retrieve (25 default, max 500) - optional
	Offset        int    `json:"offset,omitempty"` // Offset in collection - optional
}

List Translation Approvals API call

type ListWorkflowsStepsOptions

type ListWorkflowsStepsOptions struct {
	Limit  int `json:"limit,omitempty"`  // Maximum number of items to retrieve (25 default, max 500) - optional
	Offset int `json:"offset,omitempty"` // Offset in collection - optional
}

List workflow steps API call

type ResponseAddApproval

type ResponseAddApproval struct {
	Data struct {
		ID   int `json:"id"`
		User struct {
			ID        int    `json:"id"`
			Username  string `json:"username"`
			FullName  string `json:"fullName"`
			AvatarURL string `json:"avatarUrl"`
		} `json:"user"`
		TranslationID  int       `json:"translationId"`
		StringID       int       `json:"stringId"`
		LanguageID     string    `json:"languageId"`
		WorkflowStepID int       `json:"workflowStepId"`
		CreatedAt      time.Time `json:"createdAt"`
	} `json:"data"`
}

type ResponseAddStorage

type ResponseAddStorage struct {
	Data struct {
		Id       int    `json:"id"`
		FileName string `json:"fileName"`
	} `json:"data"`
}

ResponseAddStorage are response for AddStorage api call

type ResponseBuildDirectoryTranslation

type ResponseBuildDirectoryTranslation struct {
	Data struct {
		ID         int       `json:"id"`
		ProjectID  int       `json:"projectId"`
		Status     string    `json:"status"`
		Progress   int       `json:"progress"`
		CreatedAt  time.Time `json:"createdAt"`
		UpdatedAt  time.Time `json:"updatedAt"`
		FinishedAt time.Time `json:"finishedAt"`
	} `json:"data"`
}

type ResponseBuildFileTranslation

type ResponseBuildFileTranslation struct {
	Data struct {
		URL      string    `json:"url"`
		ExpireIn time.Time `json:"expireIn"`
		Etag     string    `json:"etag"`
	} `json:"data"`
}

type ResponseBuildProjectTranslation

type ResponseBuildProjectTranslation struct {
	Data struct {
		Id         int    `json:"id"`
		ProjectID  int    `json:"projectId"`
		Status     string `json:"status"`
		Progress   int    `json:"progress"`
		Attributes struct {
			BranchID                        int      `json:"branchId"`
			TargetLanguageIDs               []string `json:"targetLanguageIds"`
			SkipUntranslatedStrings         bool     `json:"skipUntranslatedStrings"`
			SkipUntranslatedFiles           bool     `json:"skipUntranslatedFiles"`
			ExportApprovedOnly              bool     `json:"exportApprovedOnly"`
			ExportWithMinApprovalsCount     int      `json:"exportWithMinApprovalsCount"`
			ExportStringsThatPassedWorkflow bool     `json:"exportStringsThatPassedWorkflow"`
		} `json:"attributes"`
	} `json:"data"`
}

type ResponseCheckProjectBuildStatus

type ResponseCheckProjectBuildStatus struct {
	Data struct {
		Id         int    `json:"id"`
		ProjectId  int    `json:"projectId"`
		Status     string `json:"status"`
		Progress   int    `json:"progress"`
		Attributes struct {
			BranchId                    int      `json:"branchId,omitempty"`
			TargetLanguageIds           []string `json:"targetLanguageIds,omitempty"`
			SkipUntranslatedStrings     bool     `json:"skipUntranslatedStrings"`
			SkipUntranslatedFiles       bool     `json:"skipUntranslatedFiles"`
			ExportApprovedOnly          bool     `json:"exportApprovedOnly,omitempty"`          // crowdin.com
			ExportWithMinApprovalsCount int      `json:"exportWithMinApprovalsCount,omitempty"` // Enterprise
		} `json:"attributes"`
	} `json:"data"`
}

type ResponseDownloadProjectTranslations

type ResponseDownloadProjectTranslations struct {
	Data struct {
		Url      string `json:"url"`
		ExpireIn string `json:"expireIn"`
	} `json: "data"`
}

type ResponseEditStrings

type ResponseEditStrings struct {
	Data struct {
		ID         int       `json:"id"`
		ProjectID  int       `json:"projectId"`
		FileID     int       `json:"fileId"`
		Identifier string    `json:"identifier"`
		Text       string    `json:"text"`
		Type       string    `json:"type"`
		Context    string    `json:"context"`
		MaxLength  int       `json:"maxLength"`
		IsHidden   bool      `json:"isHidden"`
		Revision   int       `json:"revision"`
		HasPlurals bool      `json:"hasPlurals"`
		IsIcu      bool      `json:"isIcu"`
		CreatedAt  time.Time `json:"createdAt"`
		UpdatedAt  time.Time `json:"updatedAt"`
	} `json:"data"`
}

type ResponseGetFileProgress

type ResponseGetFileProgress struct {
	Data []struct {
		Data struct {
			Words struct {
				Total      int `json:"total"`
				Translated int `json:"translated"`
				Approved   int `json:"approved"`
			} `json:"words"`
			Phrases struct {
				Total      int `json:"total"`
				Translated int `json:"translated"`
				Approved   int `json:"approved"`
			} `json:"phrases"`
			TranslationProgress int    `json:"translationProgress"`
			ApprovalProgress    int    `json:"approvalProgress"`
			LanguageId          string `json:"languageId"`
			ETag                string `json:"eTag"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

GetFileProgress api call

type ResponseGetFileRevision

type ResponseGetFileRevision struct {
	Data struct {
		Id                int `json:"id"`
		ProjectId         int `json:"projectId"`
		FileId            int `json:"fileId"`
		RestoreToRevision int `json:"restoreToRevision"`
		Info              struct {
			Added struct {
				Strings int `json:"strings"`
				Words   int `json:"words"`
			} `json:"added"`
			Deleted struct {
				Strings int `json:"strings"`
				Words   int `json:"words"`
			} `json:"deleted"`
			Updated struct {
				Strings int `json:"strings"`
				Words   int `json:"words"`
			} `json:"updated"`
		} `json:"info"`
		Date time.Time `json:"date"`
	} `json:"data"`
}

ResponseGetFileRevision are response for GetFileRevision api call

type ResponseGetProject

type ResponseGetProject struct {
	Data struct {
		ID                int       `json:"id"`
		GroupID           int       `json:"groupId"`
		UserID            int       `json:"userId"`
		SourceLanguageID  string    `json:"sourceLanguageId"`
		TargetLanguageIds []string  `json:"targetLanguageIds"`
		Name              string    `json:"name"`
		Identifier        string    `json:"identifier"`
		Description       string    `json:"description"`
		Logo              string    `json:"logo"`
		Background        string    `json:"background"`
		IsExternal        bool      `json:"isExternal"`
		ExternalType      string    `json:"externalType"`
		WorkflowID        int       `json:"workflowId"`
		HasCrowdsourcing  bool      `json:"hasCrowdsourcing"`
		PublicDownloads   bool      `json:"publicDownloads"`
		CreatedAt         time.Time `json:"createdAt"`
		UpdatedAt         time.Time `json:"updatedAt"`
		LastActivity      time.Time `json:"lastActivity"`
		TargetLanguages   []struct {
			ID                  string   `json:"id"`
			Name                string   `json:"name"`
			EditorCode          string   `json:"editorCode"`
			TwoLettersCode      string   `json:"twoLettersCode"`
			ThreeLettersCode    string   `json:"threeLettersCode"`
			Locale              string   `json:"locale"`
			AndroidCode         string   `json:"androidCode"`
			OsxCode             string   `json:"osxCode"`
			OsxLocale           string   `json:"osxLocale"`
			PluralCategoryNames []string `json:"pluralCategoryNames"`
			PluralRules         string   `json:"pluralRules"`
			PluralExamples      []string `json:"pluralExamples"`
			TextDirection       string   `json:"textDirection"`
			DialectOf           string   `json:"dialectOf"`
		} `json:"targetLanguages"`
	} `json:"data"`
}

Get Project details API call

type ResponseGetStorage

type ResponseGetStorage struct {
	Data struct {
		Id       int    `json:"id"`
		FileName string `json:"fileName"`
	} `json:"data"`
}

ResponseGetStorage are response for ListStorages api call

type ResponseGetTranslation

type ResponseGetTranslation struct {
	Data struct {
		ID                 int    `json:"id"`
		Text               string `json:"text"`
		PluralCategoryName string `json:"pluralCategoryName"`
		User               struct {
			ID        int    `json:"id"`
			Username  string `json:"username"`
			FullName  string `json:"fullName"`
			AvatarURL string `json:"avatarUrl"`
		} `json:"user"`
		Rating    int       `json:"rating"`
		CreatedAt time.Time `json:"createdAt"`
	} `json:"data"`
}

type ResponseListDirectories

type ResponseListDirectories struct {
	Data []struct {
		Data struct {
			Id            int       `json:"id"`
			ProjectId     int       `json:"projectId"`
			BranchId      int       `json:"branchId"`
			DirectoryId   int       `json:"directoryId"` // Actually parentId
			Name          string    `json:"name"`
			Title         string    `json:"title"`
			ExportPattern string    `json:"exportPattern"`
			Priority      string    `json:"priority"`
			CreatedAt     time.Time `json:"createdAt"`
			UpdatedAt     time.Time `json:"updatedAt"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

ResponseListDirectories are response for ListDirectories api call

type ResponseListFileRevisions

type ResponseListFileRevisions struct {
	Data []struct {
		Data struct {
			Id                int `json:"id"`
			ProjectId         int `json:"projectId"`
			FileId            int `json:"fileId"`
			RestoreToRevision int `json:"restoreToRevision"`
			Info              struct {
				Added struct {
					Strings int `json:"strings"`
					Words   int `json:"words"`
				} `json:"added"`
				Deleted struct {
					Strings int `json:"strings"`
					Words   int `json:"words"`
				} `json:"deleted"`
				Updated struct {
					Strings int `json:"strings"`
					Words   int `json:"words"`
				} `json:"updated"`
			} `json:"info"`
			Date time.Time `json:"date"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

ResponseListFiles are response for ListFiles api call

type ResponseListFiles

type ResponseListFiles struct {
	Data []struct {
		Data struct {
			Id          int    `json:"id"`
			ProjectId   int    `json:"projectId"`
			BranchId    int    `json:"branchId"`
			DirectoryId int    `json:"directoryId"`
			Name        string `json:"name"`
			Title       string `json:"title"`
			Type        string `json:"type"`
			RevisionId  int    `json:"revisionId"`
			Status      string `json:"status"`
			Priority    string `json:"priority"`
			Attributes  struct {
				MimeType string `json:"mimeType"`
				FileSize int    `json:"fileSize"`
			} `json:"attributes"`
			ImportOptions struct {
				FirstLineContainsHeader bool `json:"firstLineContainsHeader"`
				ImportTranslations      bool `json:"importTranslations"`
				Scheme                  struct {
					Identifier   int `json:"identifier"`
					SourcePhrase int `json:"sourcePhrase"`
					En           int `json:"en"`
					De           int `json:"de"`
				} `json:"scheme"`
			} `json:"importOptions"`
			ExportOptions struct {
				ExportPattern string `json:"exportPattern"`
			} `json:"exportOptions"`
			ExportPattern string    `json:"exportPattern"`
			CreatedAt     time.Time `json:"createdAt"`
			UpdatedAt     time.Time `json:"updatedAt"`
			Revision      int       `json:"revision"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

ResponseListFiles are response for ListFiles api call

type ResponseListProjectBuilds

type ResponseListProjectBuilds struct {
	Data []struct {
		Data struct {
			Id         int    `json:"id"`
			ProjectId  int    `json:"projectId"`
			Status     string `json:"status"`
			Progress   int    `json:"progress"`
			Attributes struct {
				BranchId                    int      `json:"branchId,omitempty"`
				TargetLanguageIds           []string `json:"targetLanguageIds,omitempty"`
				SkipUntranslatedStrings     bool     `json:"SkipUntranslatedStrings,omitempty"`
				SkipUntranslatedFiles       bool     `json:"SkipUntranslatedFiles,omitempty"`
				ExportWithMinApprovalsCount int      `json:"ExportWithMinApprovalsCount,omitempty"`
				ExportTranslatedOnly        bool     `json:"exportTranslatedOnly,omitempty"`
				ExportApprovedOnly          bool     `json:"exportApprovedOnly,omitempty"`
			} `json:"attributes"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

type ResponseListProjects

type ResponseListProjects struct {
	Data []struct {
		Data struct {
			ID                   int       `json:"id"`
			UserID               int       `json:"userId"`
			SourceLanguageID     string    `json:"sourceLanguageId"`
			TargetLanguageIds    []string  `json:"targetLanguageIds"`
			LanguageAccessPolicy string    `json:"languageAccessPolicy"`
			Name                 string    `json:"name"`
			Cname                string    `json:"cname"`
			Identifier           string    `json:"identifier"`
			Description          string    `json:"description"`
			Visibility           string    `json:"visibility"`
			Logo                 string    `json:"logo"`
			PublicDownloads      bool      `json:"publicDownloads"`
			CreatedAt            time.Time `json:"createdAt"`
			UpdatedAt            time.Time `json:"updatedAt"`
			LastActivity         time.Time `json:"lastActivity"`
			TargetLanguages      []struct {
				ID                  string   `json:"id"`
				Name                string   `json:"name"`
				EditorCode          string   `json:"editorCode"`
				TwoLettersCode      string   `json:"twoLettersCode"`
				ThreeLettersCode    string   `json:"threeLettersCode"`
				Locale              string   `json:"locale"`
				AndroidCode         string   `json:"androidCode"`
				OsxCode             string   `json:"osxCode"`
				OsxLocale           string   `json:"osxLocale"`
				PluralCategoryNames []string `json:"pluralCategoryNames"`
				PluralRules         string   `json:"pluralRules"`
				PluralExamples      []string `json:"pluralExamples"`
				TextDirection       string   `json:"textDirection"`
				DialectOf           int      `json:"dialectOf"`
			} `json:"targetLanguages"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

type ResponseListStorages

type ResponseListStorages struct {
	Data []struct {
		Data struct {
			Id       int    `json:"id"`
			FileName string `json:"fileName"`
		} `json:"data"`
	} `json:"data"`
	Pagination []struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

ResponseListStorages are response for ListStorages api call

type ResponseListStrings

type ResponseListStrings struct {
	Data []struct {
		Data struct {
			ID         int       `json:"id"`
			ProjectID  int       `json:"projectId"`
			FileID     int       `json:"fileId"`
			Identifier string    `json:"identifier"`
			Text       string    `json:"text"`
			Type       string    `json:"type"`
			Context    string    `json:"context"`
			MaxLength  int       `json:"maxLength"`
			IsHidden   bool      `json:"isHidden"`
			Revision   int       `json:"revision"`
			HasPlurals bool      `json:"hasPlurals"`
			IsIcu      bool      `json:"isIcu"`
			CreatedAt  time.Time `json:"createdAt"`
			UpdatedAt  time.Time `json:"updatedAt"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

ResponseListStrings are response for ListStrings api call

type ResponseListTranslationApprovals

type ResponseListTranslationApprovals struct {
	Data []struct {
		Data struct {
			ID   int `json:"id"`
			User struct {
				ID        int    `json:"id"`
				Username  string `json:"username"`
				FullName  string `json:"fullName"`
				AvatarURL string `json:"avatarUrl"`
			} `json:"user"`
			TranslationID  int       `json:"translationId"`
			StringID       int       `json:"stringId"`
			LanguageID     string    `json:"languageId"`
			WorkflowStepID int       `json:"workflowStepId"`
			CreatedAt      time.Time `json:"createdAt"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

type ResponseListWorkflowsSteps

type ResponseListWorkflowsSteps struct {
	Data []struct {
		Data struct {
			ID        int         `json:"id"`
			Title     string      `json:"title"`
			Type      string      `json:"type"`
			Languages []string    `json:"languages"`
			Config    interface{} `json:"config, omitempty"`
		} `json:"data"`
	} `json:"data"`
	Pagination struct {
		Offset int `json:"offset"`
		Limit  int `json:"limit"`
	} `json:"pagination"`
}

type ResponseUpdate

type ResponseUpdate struct {
	Data struct {
		Id            int    `json:"id"`
		ProjectId     int    `json:"projectId"`
		BranchId      int    `json:"branchId"`
		DirectoryId   int    `json:"directoryId"`
		Name          string `json:"name"`
		Title         string `json:"title"`
		Type          string `json:"type"`
		RevisionId    int    `json:"revisionId"`
		Status        string `json:"status"`
		Priority      string `json:"priority"`
		ImportOptions struct {
			FirstLineContainsHeader bool `json:"firstLineContainsHeader"`
			ImportTranslations      bool `json:"importTranslations"`
			Scheme                  struct {
				Identifier   int `json:"identifier"`
				SourcePhrase int `json:"sourcePhrase"`
				En           int `json:"en"`
				De           int `json:"de"`
			} `json:"scheme"`
		} `json:"importOptions"`
		ExportOptions struct {
			ExportPattern string `json:"exportPattern"`
		} `json:"exportOptions"`
		CreatedAt time.Time `json:"createdAt"`
		UpdatedAt time.Time `json:"updatedAt"`
	} `json:"data"`
}

type ResponseUpdateFile

type ResponseUpdateFile struct {
	Data struct {
		Id            int    `json:"id"`
		ProjectId     int    `json:"projectId"`
		BranchId      int    `json:"branchId"`
		DirectoryId   int    `json:"directoryId"`
		Name          string `json:"name"`
		Title         string `json:"title"`
		Type          string `json:"type"`
		RevisionId    int    `json:"revisionId"`
		Status        string `json:"status"`
		Priority      string `json:"priority"`
		ImportOptions struct {
			FirstLineContainsHeader bool `json:"firstLineContainsHeader"`
			ImportTranslations      bool `json:"importTranslations"`
			Scheme                  struct {
				Identifier   int `json:"identifier"`
				SourcePhrase int `json:"sourcePhrase"`
				En           int `json:"en"`
				De           int `json:"de"`
			} `json:"scheme"`
		} `json:"importOptions"`
		ExportOptions struct {
			ExportPattern string `json:"exportPattern"`
		} `json:"exportOptions"`
		CreatedAt time.Time `json:"createdAt"`
		UpdatedAt time.Time `json:"updatedAt"`
	} `json:"data"`
}

type ResponseUploadTranslations

type ResponseUploadTranslations struct {
	Data struct {
		ProjectID  int    `json:"projectId"`
		StorageID  int    `json:"storageId"`
		LanguageID string `json:"languageId"`
		FileID     int    `json:"fileId"`
	} `json:"data"`
}

type T_UploadTranslationFileParams

type T_UploadTranslationFileParams struct {
	LocalFileName       string        // File containing the translations to upload
	CrowdinFileName     string        // File in Crowdin where the translations will end up
	LanguageId          string        // Langugage ID as per Crowdin spec and defined as target in the project
	ImportEqSuggestions bool          // Defines whether to add translation if it's the same as the source string
	AutoApproveImported bool          // Mark uploaded translations as approved
	TranslateHidden     bool          // Allow translations upload to hidden source strings
	ResponseTimeOut     time.Duration // in seconds. The upload operation can take several minutes.

}

type UpdateFileOptions

type UpdateFileOptions struct {
	StorageId     int    `json:"storageId"`
	UpdateOption  string `json:"updateOption,omitempty"` // needs to be either: "clear_translations_and_approvals" "keep_translations" "keep_translations_and_approvals"
	ImportOptions struct {
		ContentSegmentation  bool     `json:"contentSegmentation,omitempty"`
		TranslateContent     bool     `json:"translateContent,omitempty"`
		TranslateAttributes  bool     `json:"translateAttributes,omitempty"`
		TranslatableElements []string `json:"translatableElements,omitempty"`
	} `json:"importOptions,omitempty"`
	ExportOptions struct {
		ContentSegmentation bool `json:"contentSegmentation,omitempty"`
	} `json:"exportOptions,omitempty"`
}

UpdateFile - Update a file API call

type UploadTranslationsOptions

type UploadTranslationsOptions struct {
	StorageID           int  `json:"storageId"`
	FileID              int  `json:"fileId"`
	ImportEqSuggestions bool `json:"importEqSuggestions,omitempty"`
	AutoApproveImported bool `json:"autoApproveImported,omitempty"`
	TranslateHidden     bool `json:"translateHidden,omitempty"`
}

Upload translations API call

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL