Documentation
¶
Index ¶
- Constants
- Variables
- type AvailableLanguage
- type Contributor
- type CountResult
- type Error
- type Language
- func (l *Language) AddContributor(name, email string) error
- func (l *Language) Delete() error
- func (l Language) Export(fileFormat string, filters []string, tags []string, dest io.Writer) error
- func (l *Language) ListContributors() ([]Contributor, error)
- func (l *Language) ListTerms() ([]TermTranslated, error)
- func (l *Language) RemoveContributor(email string) error
- func (l *Language) Update(terms []TermTranslation) (CountResult, error)
- type POEditor
- func (poe *POEditor) AddProject(name, description string) (*Project, error)
- func (poe *POEditor) AvailableLanguages() ([]AvailableLanguage, error)
- func (poe *POEditor) ListContributors() ([]Contributor, error)
- func (poe *POEditor) ListProjects() ([]*Project, error)
- func (poe *POEditor) Project(id int) *Project
- func (poe *POEditor) ViewProject(id int) (*Project, error)
- type Permission
- type Plural
- type Project
- func (p *Project) AddComments(comments []TermComment) (CountResult, error)
- func (p *Project) AddContributor(name, email string) error
- func (p *Project) AddLanguage(code string) error
- func (p *Project) AddTerms(terms []Term) (CountResult, error)
- func (p *Project) Delete() error
- func (p *Project) DeleteTerms(terms []TermBase) (CountResult, error)
- func (p *Project) ListContributors() ([]Contributor, error)
- func (p *Project) ListLanguages() ([]Language, error)
- func (p *Project) ListTags() ([]string, error)
- func (p *Project) ListTerms() ([]Term, error)
- func (p *Project) RemoveContributor(email string) error
- func (p *Project) Sync(terms []Term) (CountResult, error)
- func (p *Project) Update(props map[string]string) (*Project, error)
- func (p *Project) UpdateTerms(terms []TermUpdate, fuzzyTrigger bool) (CountResult, error)
- func (p *Project) Upload(reader io.Reader, options UploadOptions) (UploadResult, error)
- type Term
- type TermBase
- type TermComment
- type TermTranslated
- type TermTranslation
- type TermUpdate
- type Translation
- type UploadOptions
- type UploadResult
Constants ¶
const ( // UploadTerms is a valid value of UploadOptions.Updating UploadTerms = "terms" // UploadTermsTranslations is a valid value of UploadOptions.Updating UploadTermsTranslations = "terms_translations" // UploadTranslations is a valid value of UploadOptions.Updating UploadTranslations = "translations" )
const ( // FileFormatPO specifies a .po file FileFormatPO = "po" // FileFormatPOT specifies a .pot file FileFormatPOT = "pot" // FileFormatMO specifies a .mo file FileFormatMO = "mo" // FileFormatXLS specifies an .xls file FileFormatXLS = "xls" // FileFormatCSV specifies a .csv file FileFormatCSV = "csv" // FileFormatRESW specifies an .resw file FileFormatRESW = "resw" // FileFormatRESX specifies an .resx file FileFormatRESX = "resx" // FileFormatAndroidStrings specifies strings should be in android format FileFormatAndroidStrings = "android_strings" // FileFormatAppleStrings specifies strings should be in apple format FileFormatAppleStrings = "apple_strings" // FileFormatXLIFF specifies an .xliff file FileFormatXLIFF = "xliff" // FileFormatProperties specifies a .propterties file FileFormatProperties = "properties" // FileFormatKeyValueJSON specifies a .json file in key value format FileFormatKeyValueJSON = "key_value_json" // FileFormatJSON specifies a .json file FileFormatJSON = "json" // FileFormatXMB specifies an .xmb file FileFormatXMB = "xmb" // FileFormatXTB specifies an .xtb file FileFormatXTB = "xtb" )
const ( // FilterTranslated filters terms in translated state FilterTranslated = "translated" // FilterUntranslated filters terms in untranslated state FilterUntranslated = "untranslated" // FilterFuzzy filters terms in fuzzy state FilterFuzzy = "fuzzy" // FilterNotFuzzy filters terms in not fuzzy state FilterNotFuzzy = "not_fuzzy" // FilterAutomatic filters terms in automatic state FilterAutomatic = "automatic" // FilterNotAutomatic filters terms in not automatic state FilterNotAutomatic = "not_automatic" // FilterProofread filters terms in proofread state FilterProofread = "proofread" // FilterNotProofread filters terms in not proofread state FilterNotProofread = "not_proofread" )
Variables ¶
var ( // ErrorUploadUpdating is returned from Project.Upload when the value of // Updating is invalid ErrorUploadUpdating = errors.New("Updating must be one of terms, terms_translations or translations") // ErrorUploadLanguage is return when language code is missing ErrorUploadLanguage = errors.New("Language code is required when uploading translations") // ErrorUpdateFields is returned when passing invalid fields to Project.Update ErrorUpdateFields = errors.New("Tried to update invalid field. Valid fields are name, description, reference_language") // ErrTranslationInvalid is return when a Singular or Plural type is expected, // but something else is found ErrTranslationInvalid = errors.New("invalid translation type please use Singular or Plural") )
Functions ¶
This section is empty.
Types ¶
type AvailableLanguage ¶
AvailableLanguage is a language supported by POEditor
type Contributor ¶
type Contributor struct { Name string Email string Permissions []Permission }
type CountResult ¶
type CountResult struct { Parsed int `json:"parsed"` Added int `json:"added"` Deleted int `json:"deleted"` WithAddedComment int `json:"with_added_comment"` Updated int `json:"updated"` }
CountResult is a part of UploadResult and returned directly from Project.Sync. It shows counts for uploaded/synced terms and translations
type Language ¶
Language represents a single language of a project
func (*Language) AddContributor ¶
AddContributor adds a user as a language contributor
func (Language) Export ¶
Export extracts the language in the given fileformat. For available file formats, see the FileFormat constants. Terms can be filtered using the Filter constants. Terms can also be filtered by tags.
func (*Language) ListContributors ¶
func (l *Language) ListContributors() ([]Contributor, error)
ListContributors lists all contributors registered under the language
func (*Language) ListTerms ¶
func (l *Language) ListTerms() ([]TermTranslated, error)
ListTerms returns all terms in the project along with the translations for the language
func (*Language) RemoveContributor ¶
RemoveContributor removes a contributor from the language
func (*Language) Update ¶
func (l *Language) Update(terms []TermTranslation) (CountResult, error)
Update inserts or overwrites translations for a language TODO: add fuzzy_trigger
type POEditor ¶
type POEditor struct {
// contains filtered or unexported fields
}
POEditor is the main type used to interact with POEditor
func (*POEditor) AddProject ¶
AddProject creates a new project with the given name and description
func (*POEditor) AvailableLanguages ¶
func (poe *POEditor) AvailableLanguages() ([]AvailableLanguage, error)
AvailableLanguages lists all languages supported by POEditor. This is handy when you want to look up a particular language code.
func (*POEditor) ListContributors ¶
func (poe *POEditor) ListContributors() ([]Contributor, error)
ListContributors lists all contributors registered in POEditor
func (*POEditor) ListProjects ¶
ListProjects lists all the projects that are accessable by the used APIKey
type Permission ¶
type Project ¶
type Project struct { POEditor *POEditor ID int Name string Description string Public int Open int ReferenceLanguage string Terms int Created time.Time }
Project represents a POEditor project
func (*Project) AddComments ¶
func (p *Project) AddComments(comments []TermComment) (CountResult, error)
AddComments adds the given comments
func (*Project) AddContributor ¶
AddContributor adds a user as a project admin
func (*Project) AddLanguage ¶
AddLanguage adds a new language to the project. See POEditor.AvailableLanguages for a list of supported language codes.
func (*Project) AddTerms ¶
func (p *Project) AddTerms(terms []Term) (CountResult, error)
AddTerms adds the given terms to the project
func (*Project) DeleteTerms ¶
func (p *Project) DeleteTerms(terms []TermBase) (CountResult, error)
DeleteTerms deletes the given terms from the project
func (*Project) ListContributors ¶
func (p *Project) ListContributors() ([]Contributor, error)
ListContributors lists all contributors registered under the project
func (*Project) ListLanguages ¶
ListLanguages lists all the available languages in the project
func (*Project) ListTags ¶
ListTags returns a list of tags found on the project. This is not a standard API endpoint, but a useful helper never the less.
func (*Project) RemoveContributor ¶
RemoveContributor removes a user as a project admin
func (*Project) Sync ¶
func (p *Project) Sync(terms []Term) (CountResult, error)
Sync syncs project terms with the given list of terms.
CAUTION: this is a destructive operation. Any term not found in the input array will be deleted from the project.
func (*Project) Update ¶
Update updates the project according to the map[string]string.
... p, err := p.Update(map[string]string{ "name": "a project name", "description": "a project description" "reference_language": "a reference language code" })
Omitted key value pairs are not updated. Only `name`, `description` and `reference_language` can be updated.
func (*Project) UpdateTerms ¶
func (p *Project) UpdateTerms(terms []TermUpdate, fuzzyTrigger bool) (CountResult, error)
UpdateTerms lets you change the text, context, reference, plural and tags of terms. Setting fuzzyTrigger to true marks associated translations as fuzzy.
func (*Project) Upload ¶
func (p *Project) Upload(reader io.Reader, options UploadOptions) (UploadResult, error)
Upload uploads terms
type Term ¶
type Term struct { TermBase Plural string `json:"plural,omitempty"` Reference string `json:"reference,omitempty"` Comment string `json:"comment,omitempty"` Tags []string `json:"tags,omitempty"` Created poEditorTime `json:"created,omitempty"` Updated poEditorTime `json:"updated,omitempty"` }
Term is used when adding new terms, syncing or listing terms
type TermBase ¶
TermBase is used reference a particular term. This is only used publicly in term deletion, but it is utilzed heavliy in the code aswell.
type TermComment ¶
TermComment is used when adding a comment to a term
type TermTranslated ¶
type TermTranslated struct { Term Translation Translation `json:"translation"` }
TermTranslated is used when listing a project's terms along with translations for a language
type TermTranslation ¶
type TermTranslation struct { TermBase Translation Translation `json:"translation,omitempty"` }
TermTranslation is used when updating translations for a language
type TermUpdate ¶
type TermUpdate struct { Term NewTerm string `json:"new_term,omitempty"` NewContext string `json:"new_context,omitempty"` }
TermUpdate is used when updating terms
type Translation ¶
type Translation struct { Content interface{} `json:"content"` Fuzzy int `json:"fuzzy"` Proofread int `json:"proofread"` Updated poEditorTime `json:"updated"` }
Translation is used to update translations in POEditor. The field Content must be either a string or a Plural type.
func (*Translation) UnmarshalJSON ¶
func (t *Translation) UnmarshalJSON(bytes []byte) (err error)
UnmarshalJSON implements the json.Unmarshaler interface
type UploadOptions ¶
type UploadOptions struct { Updating string Language Language Overwrite bool SyncTerms bool Tags []string ReadFromSource bool FuzzyTrigger bool }
UploadOptions specifies options for upload of a file
type UploadResult ¶
type UploadResult struct { Terms CountResult `json:"terms"` Translations CountResult `json:"translations"` }
UploadResult is returned when uploading a file