Documentation
¶
Overview ¶
Package smartling is a client implementation of the Smartling Translation API v2 as documented at https://help.smartling.com/v1.0/reference
Index ¶
- Constants
- type APIClient
- type FileDownloadRequest
- type FileImportResult
- type FilesList
- type HttpAPIClient
- func (c *HttpAPIClient) Authenticate() error
- func (c *HttpAPIClient) DeleteFile(projectID string, uri string) error
- func (c *HttpAPIClient) DownloadFile(projectID string, uri string) (io.Reader, error)
- func (c *HttpAPIClient) DownloadTranslation(projectID string, localeID string, request FileDownloadRequest) (io.Reader, error)
- func (c *HttpAPIClient) GetFileStatus(projectID string, fileURI string) (*smfile.FileStatus, error)
- func (c *HttpAPIClient) GetProjectDetails(projectID string) (*ProjectDetails, error)
- func (c *HttpAPIClient) Import(projectID string, localeID string, request smfile.ImportRequest) (*FileImportResult, error)
- func (c *HttpAPIClient) LastModified(projectID string, request smfile.FileLastModifiedRequest) (*smfile.FileLastModifiedLocales, error)
- func (c *HttpAPIClient) ListAllFiles(projectID string, request smfile.FilesListRequest) ([]smfile.File, error)
- func (c *HttpAPIClient) ListFileTypes(projectID string) ([]smfile.FileType, error)
- func (c *HttpAPIClient) ListFiles(projectID string, request smfile.FilesListRequest) (*FilesList, error)
- func (c *HttpAPIClient) ListProjects(accountID string, request smfile.ProjectsListRequest) (*ProjectsList, error)
- func (c *HttpAPIClient) LogRequest(method string, url string, body []byte)
- func (c *HttpAPIClient) RenameFile(projectID string, oldURI string, newURI string) error
- type Locale
- type Project
- type ProjectDetails
- type ProjectsList
- type RetrievalType
Constants ¶
const ( // RetrieveDefault specifies that Smartling will decide what type of // translation will be returned. RetrieveDefault RetrievalType = "" // RetrievePending specifies that Smartling returns any translations // (including non-published translations) RetrievePending = "pending" // RetrievePublished specifies that Smartling returns only // published/pre-published translations. RetrievePublished = "published" // RetrievePseudo specifies that Smartling returns a modified version of // the original text with certain characters transformed and the text // expanded. RetrievePseudo = "pseudo" // RetrieveChromeInstrumented specifies that Smartling returns a modified // version of the original file with strings wrapped in a specific set of // Unicode symbols that can later be recognized and matched by the Chrome // Context Capture Extension RetrieveChromeInstrumented = "contextMatchingInstrumented" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient interface { Authenticate() error DeleteFile(projectID string, uri string) error DownloadFile(projectID string, uri string) (io.Reader, error) DownloadTranslation(projectID string, localeID string, request FileDownloadRequest) (io.Reader, error) GetFileStatus(projectID string, fileURI string) (*smfile.FileStatus, error) GetProjectDetails(projectID string) (*ProjectDetails, error) Import(projectID string, localeID string, request smfile.ImportRequest) (*FileImportResult, error) ListAllFiles(projectID string, request smfile.FilesListRequest) ([]smfile.File, error) ListProjects(accountID string, request smfile.ProjectsListRequest) (*ProjectsList, error) RenameFile(projectID string, oldURI string, newURI string) error }
type FileDownloadRequest ¶
type FileDownloadRequest struct { smfile.FileURIRequest Type RetrievalType IncludeOriginal bool }
FileDownloadRequest represents optional parameters for file download operation.
func (FileDownloadRequest) GetQuery ¶
func (request FileDownloadRequest) GetQuery() url.Values
GetQuery returns URL values representation of download file query params.
type FileImportResult ¶
type FilesList ¶
type FilesList struct { // TotalCount is a total files count. TotalCount int // Items contains all files matched by request. Items []smfile.File }
FilesList represents file list reply from Smartling APIa.
type HttpAPIClient ¶
type HttpAPIClient struct {
Client *smclient.Client
}
HttpAPIClient represents http Smartling API client.
func NewHttpAPIClient ¶
func NewHttpAPIClient(userID, tokenSecret string) *HttpAPIClient
NewHttpAPIClient returns new http Smartling API client with specified authentication data.
func (*HttpAPIClient) Authenticate ¶
func (c *HttpAPIClient) Authenticate() error
Authenticate checks that access and refresh tokens are valid and refreshes them if needed.
func (*HttpAPIClient) DeleteFile ¶
func (c *HttpAPIClient) DeleteFile( projectID string, uri string, ) error
DeleteFile removes specified files from project.
func (*HttpAPIClient) DownloadFile ¶
DownloadFile downloads original file from project.
func (*HttpAPIClient) DownloadTranslation ¶
func (c *HttpAPIClient) DownloadTranslation( projectID string, localeID string, request FileDownloadRequest, ) (io.Reader, error)
DownloadTranslation downloads specified translated file for specified locale. Check FileDownloadRequest for more options.
func (*HttpAPIClient) GetFileStatus ¶
func (c *HttpAPIClient) GetFileStatus( projectID string, fileURI string, ) (*smfile.FileStatus, error)
GetFileStatus returns file status.
func (*HttpAPIClient) GetProjectDetails ¶
func (c *HttpAPIClient) GetProjectDetails( projectID string, ) (*ProjectDetails, error)
GetProjectDetails returns project details for specified project.
func (*HttpAPIClient) Import ¶
func (c *HttpAPIClient) Import( projectID string, localeID string, request smfile.ImportRequest, ) (*FileImportResult, error)
Import imports specified file as translation.
func (*HttpAPIClient) LastModified ¶
func (c *HttpAPIClient) LastModified( projectID string, request smfile.FileLastModifiedRequest, ) (*smfile.FileLastModifiedLocales, error)
func (*HttpAPIClient) ListAllFiles ¶
func (c *HttpAPIClient) ListAllFiles( projectID string, request smfile.FilesListRequest, ) ([]smfile.File, error)
ListAllFiles returns all files by request, even if it requires several API calls.
func (*HttpAPIClient) ListFileTypes ¶
func (c *HttpAPIClient) ListFileTypes( projectID string, ) ([]smfile.FileType, error)
ListFileTypes returns file types list from specified project.
func (*HttpAPIClient) ListFiles ¶
func (c *HttpAPIClient) ListFiles( projectID string, request smfile.FilesListRequest, ) (*FilesList, error)
ListFiles returns files list from specified project by specified request. Returned result is paginated, so check out TotalCount struct field in the reply. API can return only 500 files at once.
func (*HttpAPIClient) ListProjects ¶
func (c *HttpAPIClient) ListProjects( accountID string, request smfile.ProjectsListRequest, ) (*ProjectsList, error)
ListProjects returns projects in specified account matching specified request.
func (*HttpAPIClient) LogRequest ¶
func (c *HttpAPIClient) LogRequest( method string, url string, body []byte, )
func (*HttpAPIClient) RenameFile ¶
func (c *HttpAPIClient) RenameFile( projectID string, oldURI string, newURI string, ) error
RenameFile renames file to new URI.
type Locale ¶
type Locale struct { // LocaleID is a unique locale ID. LocaleID string // Description describes locale. Description string // Enabled is a flag that represents is locale enabled or not. Enabled bool }
Locale represents locale for translation.
type Project ¶
type Project struct { // ProjectID is a unique project ID. ProjectID string // ProjectName is a human-friendly project name. ProjectName string // AccountUID is undocumented by Smartling API. AccountUID string // SourceLocaleID represents source locale ID for project. SourceLocaleID string // SourceLocaleDescription describes project's locale. SourceLocaleDescription string // Archived will be true if project is archived. Archived bool }
Project represents detailed project information.
type ProjectDetails ¶
type ProjectDetails struct { Project // TargetLocales represents target locales list. TargetLocales []Locale }
ProjectDetails extends Project type to contain target locales list.
type ProjectsList ¶
type ProjectsList struct { // TotalCount represents total count of projects. TotalCount int64 // Items contains projects list by specified request. Items []Project }
ProjectsList represents projects list under specified account.
type RetrievalType ¶
type RetrievalType string
RetrievalType describes type of file download. https://help.smartling.com/v1.0/reference#get_projects-projectid-locales-localeid-file
Source Files
¶
- client.go
- client_authenticate.go
- client_delete_file.go
- client_download_file.go
- client_download_translation.go
- client_file_last_modified.go
- client_file_status.go
- client_import.go
- client_list_file_types.go
- client_list_files.go
- client_list_projects.go
- client_log_request.go
- client_rename_file.go
- download_file_request.go