Adding status report in case of success

Fixing documentation

Signed-off-by: Jonas Franz <info@jonasfranz.de>
pull/1/head
Jonas Franz 7 years ago
parent a2e0098789
commit 3b88c02e43
  1. 8
      DOCS.md
  2. 1
      main.go
  3. 11
      plugin.go
  4. 11
      responses/responses.go

@ -2,8 +2,8 @@ Use the Crowdin plugin to update translation files.
You must provide in your configuration:
* `project-identifier` - Identifier of your Crowdin project
* `project-key` - API Key of your Crowdin project
* `project_identifier` - Identifier of your Crowdin project
* `project_key` - API Key of your Crowdin project
* `files` - Map of files with the crowdin file name as key and the to-upload file-path as value.
Information about API keys: https://support.crowdin.com/api/api-integration-setup/
@ -14,8 +14,8 @@ The following is a sample configuration in your .drone.yml file:
```yaml
translations:
crowdin:
project-identifier: example
project-key: 1bc29b36f623ba82aaf6724fd3b16718
project_identifier: example
project_key: 1bc29b36f623ba82aaf6724fd3b16718
files:
example: options/example.ini
example2: options/example2.ini

@ -36,7 +36,6 @@ func main() {
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
os.Exit(1)
}
}

@ -31,6 +31,7 @@ func (c Config) ToURL() string {
}
func (p Plugin) Exec() error {
p.Files = map[string]string{"locale_en-US.ini": "DOCS.md"}
if len(p.Files) > 20 {
return fmt.Errorf("20 files max are allowed to upload. %d files given", len(p.Files))
}
@ -84,6 +85,16 @@ func (p Plugin) Exec() error {
return err
}
return err_response
} else {
var success = new(responses.Success)
decoder := xml.NewDecoder(body)
decoder.CharsetReader = charset.NewReaderLabel
if err := decoder.Decode(&success); err != nil {
return err
}
for _, file := range success.Stats {
fmt.Printf("%s: %s\n", file.Name, file.Status)
}
}
return nil
}

@ -14,3 +14,14 @@ type Error struct {
func (e *Error) Error() string {
return fmt.Sprintf("Error from crowdin: %s (error code %d)", e.Message, e.Code)
}
type Success struct {
XMLName xml.Name `xml:"success"`
Stats []File `xml:"stats>file"`
}
type File struct {
XMLName xml.Name `xml:"file"`
Name string `xml:"name,attr"`
Status string `xml:"status,attr"`
}

Loading…
Cancel
Save