From 72feb9ebfcde4bc4ec5476aef195accabb21969f Mon Sep 17 00:00:00 2001 From: Danylo Negriienko Date: Sun, 30 Jun 2019 10:12:38 +0300 Subject: [PATCH] Updated readme.md --- README.md | 88 +++++++++++++++++++++++++++++++++++++++ config/config.exs.example | 9 ++-- 2 files changed, 94 insertions(+), 3 deletions(-) create mode 100755 README.md diff --git a/README.md b/README.md new file mode 100755 index 0000000..583b768 --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# YandexTranslate + +A simple Elixir interface to Cloud Yandex Translate's translation API + +## Installation + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `yandex_translate` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:yandex_translate, "~> 0.1.0"} + ] +end +``` + +## Get access to API + +### Creating a Service Account in the Yandex.Cloud + +To perform operations in Yandex.Cloud via the API, you need to [create Service Account](https://cloud.yandex.com/docs/iam/operations/sa/create) for Yandex Account. For security reasons this library doesn't support Yandex Account directly. After creating a service account, you have two options: use s or use IAM Tokens. +To perform operations in Yandex.Cloud via the API, you need API key or IAM token. + +### Getting a API_KEY + +[Create API key](https://cloud.yandex.com/docs/iam/operations/api-key/create) for a service account. + +```elixir +config :yandex_translate, + api_key: "API_KEY" +``` + +### Getting a IAM Token (**from 0.2.0**) + +[Get an IAM token](https://cloud.yandex.com/docs/iam/operations/iam-token/create-for-sa) for a service account. +In config/config.exs, add: + +```elixir +config :yandex_translate, + service_account_id: "SERVICE_ACCOUNT_ID", + authorized_key_id: "AUTHORIZED_KEY_ID", + private_key: "PRIVATE_KEY" +``` + +## Usage + +### Supported languages + +Request for getting list of supported languages is #languages. + +```elixir + YandexTranslate.languages() +``` + +### Language detection + +Request for detecting language of text is #detect. + +```elixir + YandexTranslator.detect("Hello") +``` + +### Translation + +Request for translating text is #translate. + +```elixir + YandexTranslator.translate("Hello", "ru") +``` + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/negrienko/yandex_translate. + +## License + +The hex is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). + +## Disclaimer + +Use this package at your own peril and risk. + +## Documentation + +Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) +and published on [HexDocs](https://hexdocs.pm). Once published, the docs can +be found at [https://hexdocs.pm/yandex_translate](https://hexdocs.pm/yandex_translate). diff --git a/config/config.exs.example b/config/config.exs.example index 012c0a0..0ccce0d 100755 --- a/config/config.exs.example +++ b/config/config.exs.example @@ -1,6 +1,9 @@ # use Mix.Config # config :yandex_translate, -# service_account_id: "SERVICE_ACCOUNT_ID" -# authorized_key_id: "AUTHORIZED_KEY_ID" -# private_key: "PRIVATE_KEY" \ No newline at end of file +# service_account_id: "SERVICE_ACCOUNT_ID" +# authorized_key_id: "AUTHORIZED_KEY_ID" +# private_key: "PRIVATE_KEY" + +# config :yandex_translate, +# api_key: "API_KEY"