phrase

package
v0.0.0-...-626b338 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessSettings

type AccessSettings struct {
	DownloadEnabled                      bool `json:"downloadEnabled"`
	WebEditorEnabledForLinguists         bool `json:"webEditorEnabledForLinguists"`
	ShowUserDataToLinguists              bool `json:"showUserDataToLinguists"`
	EmailNotifications                   bool `json:"emailNotifications"`
	AllowLoadingExternalContentInEditors bool `json:"allowLoadingExternalContentInEditors"`
	AllowLoadingIframes                  bool `json:"allowLoadingIframes"`
	StrictWorkflowFinish                 bool `json:"strictWorkflowFinish"`
	UseVendors                           bool `json:"useVendors"`
	LinguistsMayEditLockedSegments       bool `json:"linguistsMayEditLockedSegments"`
	LinguistsMayEditTagContent           bool `json:"linguistsMayEditTagContent"`
	LinguistsMayEditSource               bool `json:"linguistsMayEditSource"`
	LinguistsMaySetAutoPropagation       bool `json:"linguistsMaySetAutoPropagation"`
	UserMaySetInstantQA                  bool `json:"userMaySetInstantQA"`
	TriggerWebhooks                      bool `json:"triggerWebhooks"`
}

type AnalyseSettings

type AnalyseSettings struct {
	Type                             string        `json:"type"`
	IncludeFuzzyRepetitions          bool          `json:"includeFuzzyRepetitions"`
	IncludeNonTranslatables          bool          `json:"includeNonTranslatables"`
	IncludeMachineTranslationMatches bool          `json:"includeMachineTranslationMatches"`
	IncludeConfirmedSegments         bool          `json:"includeConfirmedSegments"`
	IncludeNumbers                   bool          `json:"includeNumbers"`
	IncludeLockedSegments            bool          `json:"includeLockedSegments"`
	CountSourceUnits                 bool          `json:"countSourceUnits"`
	IncludeTransMemory               bool          `json:"includeTransMemory"`
	NamingPattern                    string        `json:"namingPattern"`
	AnalyzeByLinguist                bool          `json:"analyzeByLinguist"`
	AnalyzeByLanguage                bool          `json:"analyzeByLanguage"`
	AllowAutomaticPostAnalysis       bool          `json:"allowAutomaticPostAnalysis"`
	ConfirmedSegmentsOnly            bool          `json:"confirmedSegmentsOnly"`
	ConfirmedOnlyByUsers             []interface{} `json:"confirmedOnlyByUsers"`
}

type Args

type Args map[string]string

type AsyncRequest

type AsyncRequest struct {
	ID            string        `json:"id"`
	CreatedBy     CreatedBy     `json:"createdBy"`
	DateCreated   Datetime      `json:"dateCreated"`
	Action        string        `json:"action"`
	AsyncResponse AsyncResponse `json:"asyncResponse"`
	Parent        Parent        `json:"parent"`
	Project       Project       `json:"project"`
}

type AsyncRequestInt

type AsyncRequestInt struct {
	ID            int           `json:"id"`
	CreatedBy     CreatedBy     `json:"createdBy"`
	DateCreated   Datetime      `json:"dateCreated"`
	Action        string        `json:"action"`
	AsyncResponse AsyncResponse `json:"asyncResponse"`
	Parent        ParentInt     `json:"parent"`
	Project       Project       `json:"project"`
}

type AsyncRequestResponse

type AsyncRequestResponse struct {
	AsyncRequest AsyncRequest `json:"asyncRequest"`
}

type AsyncResponse

type AsyncResponse struct {
	DateCreated  Datetime       `json:"dateCreated"`
	ErrorCode    string         `json:"errorCode"`
	ErrorDesc    string         `json:"errorDesc"`
	ErrorDetails []ErrorDetails `json:"errorDetails"`
	Warnings     []Warnings     `json:"warnings"`
}

type BusinessUnit

type BusinessUnit struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
}

type By

type By struct {
	ID        int    `json:"id"`
	UserName  string `json:"userName"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Email     string `json:"email"`
	Role      string `json:"role"`
	Active    bool   `json:"active"`
	Deleted   bool   `json:"deleted"`
}

type Client

type Client struct {
	Config
	// contains filtered or unexported fields
}

Client for Phrase TMS based on https://cloud.memsource.com/web/docs/api

func NewClient

func NewClient(redisDB *redis.Client, config Config) *Client

func (*Client) Authenticate

func (c *Client) Authenticate() error

func (*Client) CreateJob

func (c *Client) CreateJob(targetLanguages []string, path, filename string, data []byte) error

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, jobUID string, asyncRequestID string) ([]byte, error)

func (*Client) GetFileAsync

func (c *Client) GetFileAsync(ctx context.Context, jobUID string) error

func (*Client) GetJob

func (c *Client) GetJob(jobUID string) (*Job, error)

func (*Client) GetJobs

func (c *Client) GetJobs(filename string) ([]Job, error)

func (*Client) GetProject

func (c *Client) GetProject(projectID string) (*Project, error)

func (*Client) ProcessWebhook

func (c *Client) ProcessWebhook(ctx context.Context, originalRequest *http.Request, hookData []byte) (*translations.TranslatableCollection, []common.TranslationData, error)

func (*Client) SendToTranslation

func (m *Client) SendToTranslation(ctx context.Context, collection string, data []common.TranslationData) error

SendToTranslation sends the data provided to Phrase

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool)

SetDebug sets the debug flag which will print details about, and the full request and response

func (*Client) UpdateSource

func (c *Client) UpdateSource(jobs []string, filename string, data []byte) error

type Config

type Config struct {
	BaseURL     string
	Username    string
	Password    string
	ProjectUID  string
	CallbackURL string
	UserUID     string
	Debug       bool
}

type ContinuousJobInfo

type ContinuousJobInfo struct {
	DateUpdated Datetime `json:"dateUpdated"`
}

type CostCenter

type CostCenter struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
}

type CreateJobHeader

type CreateJobHeader struct {
	TargetLangs []string `json:"targetLangs"`
	CallbackURL string   `json:"callbackUrl"`
	Due         string   `json:"due,omitempty"`
	Path        string   `json:"path"`
}

type CreatedBy

type CreatedBy struct {
	UID       string `json:"uid"`
	Username  string `json:"username"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
}

type CreationTask

type CreationTask struct {
	ErrorCode    string `json:"errorCode"`
	ErrorMessage string `json:"errorMessage"`
	DataText     string `json:"dataText"`
	Status       Status `json:"status"`
}

type Datetime

type Datetime time.Time

Datetime is a custom JSON date parser that supports "Z" and "+0000" suffix as Phrase can't decide what to use.

func (Datetime) MarshalJSON

func (r Datetime) MarshalJSON() ([]byte, error)

func (*Datetime) UnmarshalJSON

func (d *Datetime) UnmarshalJSON(b []byte) error

type Domain

type Domain struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
}

type ErrorDetails

type ErrorDetails struct {
	Code    string `json:"code"`
	Args    Args   `json:"args"`
	Message string `json:"message"`
}

type Errors

type Errors struct {
	CreationTask CreationTask `json:"creationTask"`
	LastTask     LastTask     `json:"lastTask"`
}

type FinancialSettings

type FinancialSettings struct {
}

type ForbiddenStrings

type ForbiddenStrings struct {
	Enabled bool          `json:"enabled"`
	List    []interface{} `json:"list"`
}

type ImportResult

type ImportResult struct {
	Warnings []interface{} `json:"warnings"`
}

type ImportStatus

type ImportStatus struct {
	Status       Status `json:"status"`
	ErrorMessage string `json:"errorMessage"`
}

type Job

type Job struct {
	UID                   string            `json:"uid"`
	InnerID               string            `json:"innerId"`
	Status                Status            `json:"status"`
	Providers             []Providers       `json:"providers"`
	SourceLang            string            `json:"sourceLang"`
	TargetLang            string            `json:"targetLang"`
	WorkflowLevel         int               `json:"workflowLevel"`
	WorkflowStep          WorkflowStep      `json:"workflowStep"`
	Filename              string            `json:"filename"`
	DateDue               Datetime          `json:"dateDue"`
	WordsCount            int               `json:"wordsCount"`
	BeginIndex            int               `json:"beginIndex"`
	EndIndex              int               `json:"endIndex"`
	IsParentJobSplit      bool              `json:"isParentJobSplit"`
	UpdateSourceDate      Datetime          `json:"updateSourceDate"`
	UpdateTargetDate      Datetime          `json:"updateTargetDate"`
	DateCreated           Datetime          `json:"dateCreated"`
	JobReference          JobReference      `json:"jobReference"`
	Project               Project           `json:"project"`
	LastWorkflowLevel     int               `json:"lastWorkflowLevel"`
	WorkUnit              WorkUnit          `json:"workUnit"`
	ImportStatus          ImportStatus      `json:"importStatus"`
	Imported              bool              `json:"imported"`
	Continuous            bool              `json:"continuous"`
	ContinuousJobInfo     ContinuousJobInfo `json:"continuousJobInfo"`
	OriginalFileDirectory string            `json:"originalFileDirectory"`
	ServerTaskID          string            `json:"serverTaskId"`
}

type JobOnlyUID

type JobOnlyUID struct {
	UID string `json:"uid"`
}

type JobParts

type JobParts struct {
	ID               int      `json:"id"`
	UID              string   `json:"uid"`
	InternalID       string   `json:"internalId"`
	Task             string   `json:"task"`
	FileName         string   `json:"fileName"`
	TargetLang       string   `json:"targetLang"`
	WorkflowLevel    int      `json:"workflowLevel"`
	Status           Status   `json:"status"`
	WordsCount       int      `json:"wordsCount"`
	BeginIndex       int      `json:"beginIndex"`
	EndIndex         int      `json:"endIndex"`
	IsParentJobSplit bool     `json:"isParentJobSplit"`
	DateCreated      Datetime `json:"dateCreated"`
	Project          Project  `json:"project"`
}

type JobReference

type JobReference struct {
	UID              string       `json:"uid"`
	JobUID           string       `json:"jobUid"`
	Filename         string       `json:"filename"`
	SourceLocale     string       `json:"sourceLocale"`
	TargetLocale     string       `json:"targetLocale"`
	SourceLang       string       `json:"sourceLang"`
	TargetLang       string       `json:"targetLang"`
	WordCount        int          `json:"wordCount"`
	Progress         int          `json:"progress"`
	Level            int          `json:"level"`
	DueDate          Datetime     `json:"dueDate"`
	CreatedDate      Datetime     `json:"createdDate"`
	JobCreatedDate   Datetime     `json:"jobCreatedDate"`
	LastModifiedDate Datetime     `json:"lastModifiedDate"`
	Status           Status       `json:"status"`
	Project          Project      `json:"project"`
	CreatedBy        CreatedBy    `json:"createdBy"`
	Owner            Owner        `json:"owner"`
	Providers        []Providers  `json:"providers"`
	WorkflowStep     WorkflowStep `json:"workflowStep"`
	Continuous       bool         `json:"continuous"`
	LqaScore         bool         `json:"lqaScore"`
	Settings         Settings     `json:"settings"`
	Warnings         []string     `json:"warnings"`
	Errors           Errors       `json:"errors"`
}

type JobsList

type JobsList struct {
	Sort             interface{} `json:"sort"`
	PageNumber       int         `json:"pageNumber"`
	Content          []Job       `json:"content"`
	NumberOfElements int         `json:"numberOfElements"`

	TotalElements int `json:"totalElements"`
	PageSize      int `json:"pageSize"`
	TotalPages    int `json:"totalPages"`
}

type LangSettings

type LangSettings struct {
	TargetLang string `json:"targetLang"`
}

type LastModified

type LastModified struct {
	Date time.Time `json:"date"`
	By   By        `json:"by"`
}

type LastTask

type LastTask struct {
	ErrorCode    string `json:"errorCode"`
	ErrorMessage string `json:"errorMessage"`
	DataText     string `json:"dataText"`
	Status       Status `json:"status"`
}

type LoginResponse

type LoginResponse struct {
	User                               phraseUser `json:"user"`
	Token                              string     `json:"token"`
	Expires                            string     `json:"expires"`
	LastInvalidateAllSessionsPerformed string     `json:"lastInvalidateAllSessionsPerformed"`
}

type MachineTranslateSettings

type MachineTranslateSettings struct {
	ID      int    `json:"id"`
	UID     string `json:"uid"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	Default bool   `json:"default"`
	Args    Args   `json:"args"`
}

type Metadata

type Metadata struct {
	UID       string    `json:"uid"`
	FieldName string    `json:"fieldName"`
	Value     string    `json:"value"`
	Options   []Options `json:"options"`
	Project   Project   `json:"project"`
}

type Options

type Options struct {
	UID   string `json:"uid"`
	Value string `json:"value"`
}

type Organization

type Organization struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
}

type Owner

type Owner struct {
	UID       string `json:"uid"`
	Username  string `json:"username"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
}

type Parent

type Parent struct {
	ID string `json:"id"`
}

type ParentInt

type ParentInt struct {
	ID int `json:"id"`
}

type Progress

type Progress struct {
	TotalCount    int `json:"totalCount"`
	FinishedCount int `json:"finishedCount"`
	OverdueCount  int `json:"overdueCount"`
	FinishedRatio int `json:"finishedRatio"`
	OverdueRatio  int `json:"overdueRatio"`
}

type Project

type Project struct {
	UID           string       `json:"uid"`
	InnerID       int          `json:"innerId"`
	Name          string       `json:"name"`
	BusinessUnit  BusinessUnit `json:"businessUnit"`
	Domain        Domain       `json:"domain"`
	SubDomain     SubDomain    `json:"subDomain"`
	Client        Client       `json:"client"`
	CostCenter    CostCenter   `json:"costCenter"`
	DueDate       Datetime     `json:"dueDate"`
	CreatedDate   Datetime     `json:"createdDate"`
	CreatedBy     CreatedBy    `json:"createdBy"`
	Owner         Owner        `json:"owner"`
	Vendor        Vendor       `json:"vendor"`
	PurchaseOrder string       `json:"purchaseOrder"`
	SourceLang    string       `json:"sourceLang"`
	TargetLangs   []string     `json:"targetLangs"`
	Status        Status       `json:"status"`
	Progress      Progress     `json:"progress"`
	Metadata      []Metadata   `json:"metadata"`
	Note          string       `json:"note"`
	Deleted       bool         `json:"deleted"`
	Archived      bool         `json:"archived"`
}

type Providers

type Providers struct {
	UID        string   `json:"uid"`
	Names      []string `json:"names"`
	Type       string   `json:"type"`
	Anonymized bool     `json:"anonymized"`
	Deleted    bool     `json:"deleted"`
	Active     bool     `json:"active"`
}

type QualityAssuranceSettings

type QualityAssuranceSettings struct {
	EmptyTranslation               bool                `json:"emptyTranslation"`
	InconsistentTranslation        bool                `json:"inconsistentTranslation"`
	JoinTags                       bool                `json:"joinTags"`
	MissingNumbers                 bool                `json:"missingNumbers"`
	SegmentNotConfirmed            bool                `json:"segmentNotConfirmed"`
	Terminology                    bool                `json:"terminology"`
	MultipleSpaces                 bool                `json:"multipleSpaces"`
	TrailingSpace                  bool                `json:"trailingSpace"`
	TrailingPunctuation            bool                `json:"trailingPunctuation"`
	TargetLength                   TargetLength        `json:"targetLength"`
	Formatting                     bool                `json:"formatting"`
	UnresolvedComment              bool                `json:"unresolvedComment"`
	EmptyPairTags                  bool                `json:"emptyPairTags"`
	StrictJobStatus                bool                `json:"strictJobStatus"`
	ForbiddenStrings               ForbiddenStrings    `json:"forbiddenStrings"`
	ExcludeLockedSegments          bool                `json:"excludeLockedSegments"`
	IgnoreNotApprovedTerms         bool                `json:"ignoreNotApprovedTerms"`
	SpellCheck                     bool                `json:"spellCheck"`
	RepeatedWords                  bool                `json:"repeatedWords"`
	InconsistentTagContent         bool                `json:"inconsistentTagContent"`
	EmptyTagContent                bool                `json:"emptyTagContent"`
	XliffTags                      bool                `json:"xliffTags"`
	NestedTags                     bool                `json:"nestedTags"`
	ForbiddenTerms                 bool                `json:"forbiddenTerms"`
	TargetLengthPercent            TargetLengthPercent `json:"targetLengthPercent"`
	TargetLengthPerSegment         bool                `json:"targetLengthPerSegment"`
	NewerAtPrecedingWorkflowStep   bool                `json:"newerAtPrecedingWorkflowStep"`
	LeadingAndTrailingSpaces       bool                `json:"leadingAndTrailingSpaces"`
	IgnoreInAllWorkflowSteps       bool                `json:"ignoreInAllWorkflowSteps"`
	UnmodifiedFuzzyTranslation     bool                `json:"unmodifiedFuzzyTranslation"`
	UnmodifiedFuzzyTranslationTM   bool                `json:"unmodifiedFuzzyTranslationTM"`
	UnmodifiedFuzzyTranslationMTNT bool                `json:"unmodifiedFuzzyTranslationMTNT"`
	ExtraNumbers                   bool                `json:"extraNumbers"`
	TargetSourceIdentical          bool                `json:"targetSourceIdentical"`
	FuzzyInconsistency             bool                `json:"fuzzyInconsistency"`
	CustomQa                       bool                `json:"customQa"`
	DoNotTranslate                 bool                `json:"doNotTranslate"`
}

type Reference

type Reference struct {
	UID  string `json:"uid"`
	Type string `json:"type"`
}

type ResultFileRequest

type ResultFileRequest struct {
	AsyncRequest *AsyncRequest `json:"asyncRequest"`
	Reference    Reference     `json:"reference"`
}

type SecuritySettings

type SecuritySettings struct {
	CanEdit        bool `json:"canEdit"`
	CanEditDueDate bool `json:"canEditDueDate"`
	CanDelete      bool `json:"canDelete"`
}

type Settings

type Settings struct {
	SecuritySettings SecuritySettings `json:"securitySettings"`
}

type Status

type Status string
const (
	StatusAccepted            Status = "ACCEPTED"
	StatusCancelled           Status = "CANCELLED"
	StatusCompleted           Status = "COMPLETED"
	StatusCompletedByLinguist Status = "COMPLETED_BY_LINGUIST"
	StatusDeclined            Status = "DECLINED"
	StatusDelivered           Status = "DELIVERED"
	StatusEmailed             Status = "EMAILED"
	StatusNew                 Status = "NEW"
	StatusRejected            Status = "REJECTED"
)

func (Status) IsCompleted

func (s Status) IsCompleted() bool

type SubDomain

type SubDomain struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
}

type TargetLength

type TargetLength struct {
	Enabled bool `json:"enabled"`
	Max     int  `json:"max"`
}

type TargetLengthPercent

type TargetLengthPercent struct {
	Enabled bool    `json:"enabled"`
	Max     float64 `json:"max"`
}

type UpdateSourceRequest

type UpdateSourceRequest struct {
	Jobs                       []JobOnlyUID `json:"jobs"`
	PreTranslate               bool         `json:"preTranslate"`
	AllowAutomaticPostAnalysis bool         `json:"allowAutomaticPostAnalysis"`
	CallbackURL                string       `json:"callbackUrl"`
}

type Vendor

type Vendor struct {
	UID          string       `json:"uid"`
	VendorUID    string       `json:"vendorUid"`
	Username     string       `json:"username"`
	FirstName    string       `json:"firstName"`
	LastName     string       `json:"lastName"`
	Organization Organization `json:"organization"`
}

type Warnings

type Warnings struct {
	Code    string `json:"code"`
	Args    Args   `json:"args"`
	Message string `json:"message"`
}

type WebhookEvent

type WebhookEvent struct {
	JobParts  []JobParts      `json:"jobParts"`
	Metadata  WebhookMetadata `json:"metadata"`
	Event     string          `json:"event"`
	Timestamp int             `json:"timestamp"`
	EventUID  string          `json:"eventUid"`
}

type WebhookMetadata

type WebhookMetadata struct {
	Project Project `json:"project"`
}

type WebhookPost

type WebhookPost struct {
	JobParts     []JobParts       `json:"jobParts"`
	Metadata     Metadata         `json:"metadata"`
	Event        string           `json:"event"`
	Timestamp    int              `json:"timestamp"`
	EventUID     string           `json:"eventUid"`
	AsyncRequest *AsyncRequestInt `json:"asyncRequest"`
}

type WorkUnit

type WorkUnit struct {
}

type WorkflowStep

type WorkflowStep struct {
	UID          string `json:"uid"`
	Name         string `json:"name"`
	Abbreviation string `json:"abbreviation"`
	Order        int    `json:"order"`
	LqaEnabled   bool   `json:"lqaEnabled"`
}

Jump to

Keyboard shortcuts

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