| @@ 20-65 (lines=46) @@ | ||
| 17 | * |
|
| 18 | * @since 1.0.5 |
|
| 19 | */ |
|
| 20 | Class Glossary extends Package |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * Download Crowdin project glossaries as TBX file. |
|
| 24 | * |
|
| 25 | * @param boolean $includeAssigned Defines whether the assigned glossaries should be included in downloaded TBX file. |
|
| 26 | * Acceptable values are: 0, 1. |
|
| 27 | * Default is 1. |
|
| 28 | * |
|
| 29 | * @since 1.0.5 |
|
| 30 | * @see https://crowdin.com/page/api/download-glossary |
|
| 31 | * |
|
| 32 | * @return ResponseInterface |
|
| 33 | */ |
|
| 34 | public function download(bool $includeAssigned = true) : ResponseInterface |
|
| 35 | { |
|
| 36 | return $this->getHttpClient() |
|
| 37 | ->get($this->getBasePath('download-glossary') . '&include_assigned=' . (int) $includeAssigned); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Upload your Translation Memory for Crowdin Project in TMX file format. |
|
| 42 | * |
|
| 43 | * @param string $file Full path to file to upload. |
|
| 44 | * |
|
| 45 | * @since 1.0.5 |
|
| 46 | * @see https://crowdin.com/page/api/upload-glossary |
|
| 47 | * |
|
| 48 | * @return ResponseInterface |
|
| 49 | */ |
|
| 50 | public function upload(string $file) : ResponseInterface |
|
| 51 | { |
|
| 52 | if (false === file_exists($file)) |
|
| 53 | { |
|
| 54 | throw new \UnexpectedValueException('File not found for upload'); |
|
| 55 | } |
|
| 56 | ||
| 57 | $data = [[ |
|
| 58 | 'name' => 'file', |
|
| 59 | 'contents' => fopen($file, 'r') |
|
| 60 | ]]; |
|
| 61 | ||
| 62 | return $this->getHttpClient() |
|
| 63 | ->post($this->getBasePath('upload-glossary'), ['multipart' => $data]); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 20-65 (lines=46) @@ | ||
| 17 | * |
|
| 18 | * @since 1.0.5 |
|
| 19 | */ |
|
| 20 | Class Memory extends Package |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * Download Crowdin project Translation Memory as TMX file. |
|
| 24 | * |
|
| 25 | * @param boolean $includeAssigned Defines whether the assigned TMs should be included in downloaded TMX file. |
|
| 26 | * Acceptable values are: 0, 1. |
|
| 27 | * Default is 1. |
|
| 28 | * |
|
| 29 | * @since 1.0.5 |
|
| 30 | * @see https://crowdin.com/page/api/download-tm |
|
| 31 | * |
|
| 32 | * @return ResponseInterface |
|
| 33 | */ |
|
| 34 | public function download(bool $includeAssigned = true) : ResponseInterface |
|
| 35 | { |
|
| 36 | return $this->getHttpClient() |
|
| 37 | ->get($this->getBasePath('download-tm') . '&include_assigned=' . (int) $includeAssigned); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Upload your Translation Memory for Crowdin Project in TMX file format. |
|
| 42 | * |
|
| 43 | * @param string $file Full path to file to upload. |
|
| 44 | * |
|
| 45 | * @since 1.0.5 |
|
| 46 | * @see https://crowdin.com/page/api/upload-tm |
|
| 47 | * |
|
| 48 | * @return ResponseInterface |
|
| 49 | */ |
|
| 50 | public function upload(string $file) : ResponseInterface |
|
| 51 | { |
|
| 52 | if (false === file_exists($file)) |
|
| 53 | { |
|
| 54 | throw new \UnexpectedValueException('File not found for upload'); |
|
| 55 | } |
|
| 56 | ||
| 57 | $data = [[ |
|
| 58 | 'name' => 'file', |
|
| 59 | 'contents' => fopen($file, 'r') |
|
| 60 | ]]; |
|
| 61 | ||
| 62 | return $this->getHttpClient() |
|
| 63 | ->post($this->getBasePath('upload-tm'), ['multipart' => $data]); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||