poedit

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToUnmarshalResponse = errors.New("Failed to unmarshal response")
	ErrNotImplemented            = errors.New("Method is not implemented")
)
View Source
var ContentMetaMap = map[string]ContentMeta{
	"pot":             {Extension: "pot", Type: "text/plain; charset=utf-8"},
	"po":              {Extension: "po", Type: "text/plain; charset=utf-8"},
	"mo":              {Extension: "mo", Type: "application/octet-stream"},
	"xls":             {Extension: "xls", Type: "application/vnd.ms-excel"},
	"xlsx":            {Extension: "xlsx", Type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
	"csv":             {Extension: "csv", Type: "text/csv; charset=utf-8"},
	"ini":             {Extension: "ini", Type: "text/plain; charset=utf-8"},
	"resw":            {Extension: "resw", Type: "application/xml"},
	"resx":            {Extension: "resx", Type: "application/xml"},
	"android_strings": {Extension: "xml", Type: "application/xml"},
	"apple_strings":   {Extension: "strings", Type: "text/plain; charset=utf-8"},
	"xliff":           {Extension: "xliff", Type: "application/xml"},
	"properties":      {Extension: "properties", Type: "text/plain; charset=utf-8"},
	"key_value_json":  {Extension: "json", Type: "application/json"},
	"json":            {Extension: "json", Type: "application/json"},
	"yml":             {Extension: "yml", Type: "text/plain; charset=utf-8"},
	"xlf":             {Extension: "xlf", Type: "application/xml"},
	"xmb":             {Extension: "xmb", Type: "application/xml"},
	"xtb":             {Extension: "xtb", Type: "application/xml"},
	"arb":             {Extension: "arb", Type: "application/json"},
	"rise_360_xliff":  {Extension: "xliff", Type: "application/xml"},
}
View Source
var ErrNoExtensionMetaFound = errors.New("no extension meta found for specified format")

Functions

This section is empty.

Types

type AddProjectLanguageRequest

type AddProjectLanguageRequest struct {
	ID       int
	Language string
}

type AddProjectLanguageResponse

type AddProjectLanguageResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
}

type AddProjectRequest

type AddProjectRequest struct {
	Name        string
	Description string
}

type AddProjectResponse

type AddProjectResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Project struct {
			ID                int64  `json:"id"`
			Name              string `json:"name"`
			Description       string `json:"description"`
			Public            int64  `json:"public"`
			Open              int64  `json:"open"`
			ReferenceLanguage string `json:"reference_language"`
			Terms             int64  `json:"terms"`
			Created           string `json:"created"`
		} `json:"project"`
	} `json:"result"`
}

type Client

type Client interface {
	ExportProject(ctx context.Context, req ExportProjectRequest) (result *ExportProjectResponse, err error)
}

Client is an interface to poeditors api

type ClientImpl

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

ClientImpl is an implementation of the poeditor client interface

func NewClient

func NewClient(apiToken string, httpClient *http.Client) *ClientImpl

NewClient creates a new poeditor api client

func (*ClientImpl) AddProject

AddProject creates a new project. Returns project details (if successful).

https://poeditor.com/docs/api#projects_add

func (*ClientImpl) AddProjectlanguage

AddProjectLanguage Adds a new language to project.

https://poeditor.com/docs/api#languages_add

func (*ClientImpl) DeleteProject

DeleteProject Deletes the project from the account. You must be the owner of the project.

https://poeditor.com/docs/api#projects_delete

func (*ClientImpl) DeleteProjectLanguage

DeleteProjectLanguage Deletes existing language from project.

https://poeditor.com/docs/api#languages_delete

func (*ClientImpl) ExportProject

ExportProject Returns the link of the file (expires after 10 minutes).

https://poeditor.com/docs/api#projects_export

func (*ClientImpl) ListAvailableLanguages

func (c *ClientImpl) ListAvailableLanguages(ctx context.Context) (*ListAvailableLanguagesResponse, error)

ListAvailableLanguages Returns a comprehensive list of all languages supported by POEditor.

https://poeditor.com/docs/api#languages_available

func (*ClientImpl) ListProjectLanguages

ListProjectLanguages Returns project languages, percentage of translation done for each and the datetime (UTC - ISO 8601) when the last change was made.

https://poeditor.com/docs/api#languages_list

func (*ClientImpl) ListProjects

func (c *ClientImpl) ListProjects(ctx context.Context) (*ListProjectsResponse, error)

ListProjects returns the list of projects owned by user.

https://poeditor.com/docs/api#projects_list

func (*ClientImpl) SyncProjectTerms

SyncProjectTerms Syncs your project with the array you send (terms that are not found in the JSON object will be deleted from project and the new ones added). Please use with caution. If wrong data is sent, existing terms and their translations might be irreversibly lost.

https://poeditor.com/docs/api#projects_sync

func (*ClientImpl) UpdateProjectLanguage

UpdateProjectLanguage Inserts / overwrites translations.

https://poeditor.com/docs/api#languages_update

NOT IMPLEMENTED in this sdk

func (*ClientImpl) UpdateProjectSettings

UpdateProjectSettings Updates project settings (name, description, reference language) If optional parameters are not sent, their respective fields are not updated.

https://poeditor.com/docs/api#projects_update

func (*ClientImpl) UploadProject

UploadProject Updates terms / translations - No more than one request every 30 seconds.

https://poeditor.com/docs/api#projects_upload

NOT IMPLEMENTED In this sdk

func (*ClientImpl) ViewProject

ViewProject returns project's details.

https://poeditor.com/docs/api#projects_view

type ContentMeta

type ContentMeta struct {
	Extension, Type string
}

func GetContentMeta

func GetContentMeta(format string) (*ContentMeta, error)

type DeleteProjectLanguageRequest

type DeleteProjectLanguageRequest struct {
	ID       int
	Language string
}

type DeleteProjectLanguageResponse

type DeleteProjectLanguageResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
}

type DeleteProjectRequest

type DeleteProjectRequest struct {
	ID int
}

type DeleteProjectResponse

type DeleteProjectResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
}

type ErrLanguageNotFound

type ErrLanguageNotFound struct {
	ProjectID    int
	LanguageCode string
}

func (*ErrLanguageNotFound) Error

func (e *ErrLanguageNotFound) Error() string

type ErrProjectPermissionDenied

type ErrProjectPermissionDenied struct {
	ProjectID int
}

func (*ErrProjectPermissionDenied) Error

type ExportProjectRequest

type ExportProjectRequest struct {
	ID       int
	Language string
	Type     string
	Order    string
	Tags     []string
	Filters  []string
	Options  []string
}

type ExportProjectResponse

type ExportProjectResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		URL string `json:"url"`
	} `json:"result"`
}

type ListAvailableLanguagesResponse

type ListAvailableLanguagesResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Languages []struct {
			Name string `json:"name"`
			Code string `json:"code"`
		} `json:"languages"`
	} `json:"result"`
}

type ListProjectLanguagesRequest

type ListProjectLanguagesRequest struct {
	ID int
}

type ListProjectLanguagesResponse

type ListProjectLanguagesResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Languages []struct {
			Name         string  `json:"name"`
			Code         string  `json:"code"`
			Translations int64   `json:"translations"`
			Percentage   float64 `json:"percentage"`
			Updated      string  `json:"updated"`
		} `json:"languages"`
	} `json:"result"`
}

type ListProjectsResponse

type ListProjectsResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Projects []struct {
			ID      int64  `json:"id"`
			Name    string `json:"name"`
			Public  int64  `json:"public"`
			Open    int64  `json:"open"`
			Created string `json:"created"`
		} `json:"projects"`
	} `json:"result"`
}

type SyncProjectTermsRequest

type SyncProjectTermsRequest struct {
	ID   int
	Data []struct {
		Term      string   `json:"term"`
		Context   string   `json:"context"`
		Reference string   `json:"reference"`
		Plural    string   `json:"plural"`
		Comment   string   `json:"comment,omitempty"`
		Tags      []string `json:"tags"`
	}
}

type SyncProjectTermsResponse

type SyncProjectTermsResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Terms struct {
			Parsed  int64 `json:"parsed"`
			Added   int64 `json:"added"`
			Updated int64 `json:"updated"`
			Deleted int64 `json:"deleted"`
		} `json:"terms"`
	} `json:"result"`
}

type UpdateProjectLanguageRequest

type UpdateProjectLanguageRequest struct {
	ID   int
	Data []struct{}
}

type UpdateProjectLanguageResponse

type UpdateProjectLanguageResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Translations struct {
			Parsed  int64 `json:"parsed"`
			Added   int64 `json:"added"`
			Updated int64 `json:"updated"`
		} `json:"translations"`
	} `json:"result"`
}

type UpdateProjectSettingsRequest

type UpdateProjectSettingsRequest struct {
	ID                int
	Name              string
	Description       string
	ReferenceLanguage string
}

type UpdateProjectSettingsResponse

type UpdateProjectSettingsResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Project struct {
			ID                int64  `json:"id"`
			Name              string `json:"name"`
			Description       string `json:"description"`
			Public            int64  `json:"public"`
			Open              int64  `json:"open"`
			ReferenceLanguage string `json:"reference_language"`
			Terms             int64  `json:"terms"`
			Created           string `json:"created"`
		} `json:"project"`
	} `json:"result"`
}

type UploadProjectRequest

type UploadProjectRequest struct {
	ID             int
	Updating       string
	File           io.Reader
	Language       string
	Overwrite      bool
	SyncTerms      bool
	Tags           string
	ReadFromSource bool
	FuzzyTrigger   bool
}

type UploadProjectResponse

type UploadProjectResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Terms struct {
			Parsed  int64 `json:"parsed"`
			Added   int64 `json:"added"`
			Deleted int64 `json:"deleted"`
		} `json:"terms"`
		Translations struct {
			Parsed  int64 `json:"parsed"`
			Added   int64 `json:"added"`
			Updated int64 `json:"updated"`
		} `json:"translations"`
	} `json:"result"`
}

type ViewProjectRequest

type ViewProjectRequest struct {
	ID int
}

type ViewProjectResponse

type ViewProjectResponse struct {
	Response struct {
		Status  string `json:"status"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"response"`
	Result struct {
		Project struct {
			ID                int64  `json:"id"`
			Name              string `json:"name"`
			Description       string `json:"description"`
			Public            int64  `json:"public"`
			Open              int64  `json:"open"`
			ReferenceLanguage string `json:"reference_language"` // nolint:tagliatelle
			Terms             int64  `json:"terms"`
			Created           string `json:"created"`
		} `json:"project"`
	} `json:"result"`
}

ViewProjectResponse is the response as it is resturned by the poeditor api.

Jump to

Keyboard shortcuts

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