{"id":20005644,"url":"https://github.com/digitaldias/translate","last_synced_at":"2026-06-08T06:34:23.373Z","repository":{"id":90536471,"uuid":"87284408","full_name":"digitaldias/Translate","owner":"digitaldias","description":"Wrapper for using the Microsoft Cognitive Translation Service","archived":false,"fork":false,"pushed_at":"2018-09-17T10:16:45.000Z","size":72,"stargazers_count":1,"open_issues_count":7,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T00:49:03.833Z","etag":null,"topics":["csharp","ddd","microsoft-cognitive-services","solid","translate"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitaldias.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-04-05T08:17:40.000Z","updated_at":"2018-09-17T10:16:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"47a2c494-2f26-4767-ad52-d90e1419d169","html_url":"https://github.com/digitaldias/Translate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/digitaldias/Translate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldias%2FTranslate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldias%2FTranslate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldias%2FTranslate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldias%2FTranslate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitaldias","download_url":"https://codeload.github.com/digitaldias/Translate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldias%2FTranslate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34051769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"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":["csharp","ddd","microsoft-cognitive-services","solid","translate"],"created_at":"2024-11-13T05:41:36.631Z","updated_at":"2026-06-08T06:34:23.337Z","avatar_url":"https://github.com/digitaldias.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![BCH compliance](https://bettercodehub.com/edge/badge/digitaldias/Translate?branch=master)](https://bettercodehub.com/)\n\n# Translate\nThis repository defines  the **TranslationService** and includes a sample console application to translate text between all supported languages of the [Microsoft Cognitive Translation API](https://www.microsoft.com/cognitive-services/en-us/translator-api)\n\n**TranslationService** automatically requests a new authentication token every 9 minutes (Translate API provides a 10-minute token), and performs the Microsoft Translation API calls masking away the details of each REST invocation.\u003cbr /\u003e\n\u003cbr /\u003e\nThe list of API methods can be found [here](http://docs.microsofttranslator.com/text-translate.html#!/default).\n\n## TranslationService Details\n### Methods and properties\n```csharp\n// Translate text from one language to another\nstring TranslateSingle(TranslationRequest)\n\n// Dictionary of supported languages, populated during startup\nDictionary\u003cstring,Language\u003e SupportedLanguages { get; }\n\n// Detect the language used in a chunk of text\nLanguage DetectLanguage(string text)\n\n// Break a text up into sentences and then return the character length for each sentence\nIEnumerable\u003cint\u003e BreakSentences(Language language, string text)\n\n```\n\n### Entities\n```csharp\n   public class Language\n   {\n        public string Name { get; set; }\n        public string Code { get; set; }\n   }\n   \n   public class TranslationRequest\n   {\n        public Language From { get; set; }\n        public Language To   { get; set; }\n        public string   Text { get; set; }\n   }\n```\n\n\n## Quickstart / Running the code \n* Follow [this guide](http://docs.microsofttranslator.com/text-translate.html) to create a cognitive services client in Azure\n* Create the file **Translate-Secrets.json** in your **My Documents** folder and paste in the Json structure at the bottom of this document. \n\n\n## Contributions welcome!\nI'm happy to accept any contributions to make this wrapper as useful as possible! The more, the merrier!\nA couple of notes: \n- The project was written in [Visual Studio 2017](https://www.visualstudio.com). In order to work on this code, you only need the Community Edition.\n- Please write [useful commit messages](https://chris.beams.io/posts/git-commit/)\n- I am a strong believer in Unit-Testing and TDD. Please ensure adequate test-coverage for your logic\n    - [XUnit.Net](https://xunit.github.io/) is used as the test framwork\n- Follow the code-style used. It is based on proven patterns and practices :)\n\n\n## A note on secrets\nYou need to provide the Account Name and key to the framework, and of course, saving that into source-code is not considered great practice.\u003cbr /\u003e\n\nThe framework therefore exposes the following interface named **ISettingsReader**:\n\n```csharp\nnamespace Translate.Domain.Contracts\n{\n    public interface ISettingsReader\n    {\n        string this[string name] { get; }\n    }\n}\n```\nThe implementation of this interface can be found in the **Translate.Data.File** project, where I'm simply reading the settings from a Json file stored in **My Documents**. \n\n\nYou can implement your own *SettingsReader* to obtain the AccountName and AccountKey, or you can opt-in on the already\nprovided implementation\n\nIn the project, the console application is named **Translate.exe** so there is a corresponding\u003cbr /\u003e\n***Translate-Secrets.Json*** in my **My Documents** folder\n\n## Attributions\nThe following external nuGet packages are part of the solution:\n\n| Nuget Package                                                                                 | Purpose                           |\n| -------------                                                                                 | -------                           |\n| [StructureMap](http://www.nuget.org/packages/StructureMap/)                                   | IoC Container                     | \n| [StructureMap.AutoMocking.Moq](http://www.nuget.org/packages/structuremap.automocking.moq/)   | For baseclass in unit-testing     | \n| [Moq](http://www.nuget.org/packages/Moq/)                                                     | My favourite mocking framework    |\n| [Should](http://www.nuget.org/packages/Should/)                                               | For writing fluent assertions     |\n| [NewtonSoft.Json](https://www.nuget.org/packages/Newtonsoft.Json)                             | For working with Json             |\n| [xUnit](http://www.nuget.org/packages/xunit/)                                                 | Unit testing framework            |\n| [RestSharp](http://www.nuget.org/packages/RestSharp/)                                         | for performing restful operations |\n| [nBuilder](https://code.google.com/archive/p/nbuilder/)                                       | For rapid testdata creation       |\n\n\n## Resources\n\nContents of Translate-Secrets.json:\n```Json\n{\n    \"Translator:AccountName\" : \"[Your Account Name]\",\n    \"Translator:AccountKey\"  : \"[Your Account Key]\"\n}\n```\nSave this file in **My Documents** folder\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldias%2Ftranslate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitaldias%2Ftranslate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldias%2Ftranslate/lists"}