Search code examples
curllocalizationgettextzanata

Zanata: Value 'txt' is not a recognized document type. What does it mean?


I tried to send .pot file to Zanata 4 with API (https://github.com/zanata/zanata-platform/wiki/Raw-File-REST-API#source-document-upload)

my Zanata server: //my-zanata-server/zanata/rest/file/source/p1/v1?docId=document

curl -F type=txt -F [email protected] -F hash=`md5sum document.txt | awk '{print }'` -F first=true -F last=true -H "X-Auth-User:{username}" -H "X-Auth-Token:{api key}" "https//my-zanata-server/zanata/rest/file/source/p1/v1?docId=document"

But Zanata says: Value 'txt' is not a recognized document type.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><chunkUploadResponse xmlns="http://zanata.org/namespace/api/"><acceptedChunks>0</acceptedChunks><errorMessage>Value 'txt' is not a recognized document type.</errorMessage><expectingMore>false</expectingMore></chunkUploadResponse>

Also I sent other types as pot, po, etc, but the result was the same. How can I fix it?


Solution

  • You have to use a type from the type list

    GET /file/file_type_info
    Accept: application/json
    

    It looks like

    [
      {
        "type": {
          "name": "GETTEXT"
        },
        "extensions": {
          "pot": "po"
        }
      },
      {
        "type": {
          "name": "HTML"
        },
        "extensions": {
          "htm": "htm",
          "html": "html"
        }
      },
      {
        "type": {
          "name": "IDML"
        },
        "extensions": {
          "idml": "idml"
        }
      },
      {
        "type": {
          "name": "JSON"
        },
        "extensions": {
          "json": "json"
        }
      },
      {
        "type": {
          "name": "OPEN_DOCUMENT_GRAPHICS"
        },
        "extensions": {
          "odg": "odg"
        }
      },
      {
        "type": {
          "name": "OPEN_DOCUMENT_PRESENTATION"
        },
        "extensions": {
          "odp": "odp"
        }
      },
      {
        "type": {
          "name": "OPEN_DOCUMENT_SPREADSHEET"
        },
        "extensions": {
          "ods": "ods"
        }
      },
      {
        "type": {
          "name": "OPEN_DOCUMENT_TEXT"
        },
        "extensions": {
          "odt": "odt"
        }
      },
      {
        "type": {
          "name": "PLAIN_TEXT"
        },
        "extensions": {
          "txt": "txt"
        }
      },
      {
        "type": {
          "name": "PROPERTIES"
        },
        "extensions": {
          "properties": "properties"
        }
      },
      {
        "type": {
          "name": "PROPERTIES_UTF8"
        },
        "extensions": {
          "properties": "properties"
        }
      },
      {
        "type": {
          "name": "SUBTITLE"
        },
        "extensions": {
          "sub": "sub",
          "srt": "srt",
          "sbt": "sbt",
          "vtt": "vtt"
        }
      },
      {
        "type": {
          "name": "TS"
        },
        "extensions": {
          "ts": "ts"
        }
      },
      {
        "type": {
          "name": "XLIFF"
        },
        "extensions": {
          "xlf": "xlf"
        }
      },
      {
        "type": {
          "name": "XML_DOCUMENT_TYPE_DEFINITION"
        },
        "extensions": {
          "dtd": "dtd"
        }
      }
    ]
    

    So, in my case it must be GETTEXT