{"id":18772745,"url":"https://github.com/sctg-development/azure-translator-document-api-example","last_synced_at":"2025-10-14T05:15:32.193Z","repository":{"id":250905461,"uuid":"835805480","full_name":"sctg-development/azure-translator-document-api-example","owner":"sctg-development","description":"Azure Translator Document API Example","archived":false,"fork":false,"pushed_at":"2024-07-31T12:08:21.000Z","size":39,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T08:58:26.992Z","etag":null,"topics":["azure","azure-translator"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sctg-development.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-30T15:05:29.000Z","updated_at":"2025-03-06T10:26:43.000Z","dependencies_parsed_at":"2024-11-07T19:48:26.365Z","dependency_job_id":null,"html_url":"https://github.com/sctg-development/azure-translator-document-api-example","commit_stats":null,"previous_names":["sctg-development/azure-translator-api"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/sctg-development/azure-translator-document-api-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fazure-translator-document-api-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fazure-translator-document-api-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fazure-translator-document-api-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fazure-translator-document-api-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sctg-development","download_url":"https://codeload.github.com/sctg-development/azure-translator-document-api-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fazure-translator-document-api-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018014,"owners_count":26086237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-translator"],"created_at":"2024-11-07T19:30:04.297Z","updated_at":"2025-10-14T05:15:32.175Z","avatar_url":"https://github.com/sctg-development.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Azure Translator Document API Example\n\nThis project demonstrates the usage of Azure Translator Document API to translate supported documents from one language to another using the command line. It leverages Azure Blob Storage for temporary file storage during the translation process.\n\n## Features\n\n- Translate documents using Azure Translator Document API\n- Auto-detect source language if not specified\n- Upload and download files from Azure Blob Storage\n- Generate and use SAS tokens for secure blob access\n- Verbose logging option for debugging\n- Configuration via config file\n\n## Prerequisites\n\n- Go (version 1.21 or higher)\n- An Azure account with access to:\n  - Azure Translator API (Document Translation feature)\n  - Azure Blob Storage\n\n## Installation\n\nClone this repository and navigate to the project directory:\n\n```sh\ngit clone \u003cREPOSITORY_URL\u003e\ncd \u003cDIRECTORY_NAME\u003e\n```\n\n## Configuration\n\nSet up the following environment variables or provide them as command-line arguments:\n\n```bash\nexport BLOB_STORAGE_ACCOUNT_NAME=\"your_blob_storage_account_name\"\nexport BLOB_STORAGE_ACCOUNT_KEY=\"your_blob_storage_account_key\"\nexport BLOB_STORAGE_CONTAINER_NAME=\"your_container_name\"\nexport TRANSLATOR_ENDPOINT=\"https://your_translator.cognitiveservices.azure.com/\"\nexport TRANSLATOR_KEY=\"your_translator_api_key\"\nexport TRANSLATOR_REGION=\"your_azure_region\"\n```\n\nAlternatively, you can use a configuration file to provide these settings.\n\n### Using a Config File\n\nYou can use a JSON config file to specify the configuration options. Create a JSON file (e.g., `config.json`) with the following structure:\n\n```json\n{\n  \"blobAccountName\": \"your_blob_storage_account_name\",\n  \"blobAccountKey\": \"your_blob_storage_account_key\",\n  \"blobContainerName\": \"your_container_name\",\n  \"translatorEndpoint\": \"https://your_translator.cognitiveservices.azure.com/\",\n  \"translatorKey\": \"your_translator_api_key\",\n  \"translatorRegion\": \"your_azure_region\",\n  \"timeout\": 30,\n  \"verbose\": true\n}\n```\n\nRun the program using the `-config` option:\n\n```sh\n./translator -config ./config.json -in ./input_file.docx -out ./output_file.docx -to fr\n```\n\n## Usage\n\n### Build the program\n\n```sh\ngo build -o translator\n```\n\n### Run the program\n\n```sh\n./translator -in ./input_file.docx -out ./output_file.docx -to fr -v\n```\n\n### Command-line Arguments\n\n- `-endpoint`: Azure Translator API endpoint (default: TRANSLATOR_ENDPOINT env var)\n- `-key`: Azure Translator API key (default: TRANSLATOR_KEY env var)\n- `-region`: Azure region (default: TRANSLATOR_REGION env var)\n- `-in`: Input file path (required)\n- `-out`: Output file path (required)\n- `-from`: Source language (optional, auto-detected if not provided)\n- `-to`: Target language (required)\n- `-blobAccount`: Azure Blob Storage account name (default: BLOB_STORAGE_ACCOUNT_NAME env var)\n- `-blobAccountKey`: Azure Blob Storage account key (default: BLOB_STORAGE_ACCOUNT_KEY env var)\n- `-blobContainer`: Azure Blob Storage container name (default: BLOB_STORAGE_CONTAINER_NAME env var)\n- `-timeout`: Timeout in seconds (default: 30)\n- `-v`: Enable verbose logging\n\n## How It Works\n\n1. The program generates a unique job ID for the translation task.\n2. It uploads the input file to Azure Blob Storage.\n3. A JSON document is generated with translation parameters and SAS URLs.\n4. The document is submitted for translation using the Azure Translator Document API.\n5. The program waits for the translation to complete, polling the output blob.\n6. Once ready, the translated document is downloaded to the specified output path.\n7. Temporary blobs are deleted from Azure Blob Storage.\n\n## Testing\n\nRun the tests with:\n\n```bash\nexport BLOB_STORAGE_ACCOUNT_NAME=\"my_blob_store\"\nexport BLOB_STORAGE_ACCOUNT_KEY=\"MWIxYmYwMjJhMGU1MTdhMWRkZDE1YjM1OGJiNmIzOTIyYjc5MWRhNzViZTBmNTQzMTYxNWM4NWMwM2JiY2M1Ngo=\"\nexport BLOB_STORAGE_CONTAINER_NAME=\"translator\"\nexport TRANSLATOR_ENDPOINT=\"https://mytranslator.cognitiveservices.azure.com/\"\nexport TRANSLATOR_KEY=\"ebe909c559af69d7b285bfb246b214b8\"\nexport TRANSLATOR_REGION=\"westeurope\"\ngo test -v ./internal/translator\n```\n\n## License\n\nThis project is licensed under the AGPLv3 License. See the LICENSE file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsctg-development%2Fazure-translator-document-api-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsctg-development%2Fazure-translator-document-api-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsctg-development%2Fazure-translator-document-api-example/lists"}