README.md in deepl-rb-2.2.4 vs README.md in deepl-rb-2.3.0

- old
+ new

@@ -38,15 +38,43 @@ You can also configure the API host and the API version: ```rb DeepL.configure do |config| config.auth_key = 'your-api-token' - config.host = 'https://test-api.deepl.com' # Default value is 'https://api.deepl.com' + config.host = 'https://api-free.deepl.com' # Default value is 'https://api.deepl.com' config.version = 'v1' # Default value is 'v2' end ``` +### Available languages + +Available languages can be retrieved via API: + +```rb +languages = DeepL.languages + +puts languages.class +# => Array +puts languages.first.class +# => DeepL::Resources::Language +puts "#{languages.first.code} -> #{languages.first.name}" +# => "ES -> Spanish" +``` + +Note that source and target languages may be different, which can be retrieved by using the `type` +option: + +```rb +puts DeepL.languages(type: :source).count +# => 24 +puts DeepL.languages(type: :target).count +# => 26 +``` + +All languages are also defined on the +[official API documentation](https://www.deepl.com/docs-api/translating-text/) + ### Translate To translate a simple text, use the `translate` method: ```rb @@ -77,24 +105,10 @@ # => Array puts translations.first.class # => DeepL::Resources::Text ``` -Here's a list of available language codes: - -| Language code | Language -| --------------- | --------------- -| `EN` | English -| `DE` | German -| `FR` | French -| `ES` | Spanish -| `PT` | Portuguese -| `IT` | Italian -| `NL` | Dutch -| `PL` | Polish -| `RU` | Russian - You can also use custom query parameters, like `tag_handling`, `split_sentences`, `non_splitting_tags` or `ignore_tags`: ```rb translation = DeepL.translate '<p>A sample</p>', 'EN', 'ES', tag_handling: 'xml', split_sentences: false, @@ -111,10 +125,10 @@ | `preserve_formatting` | Converts `false` to `'0'` and `true` to `'1'` | `split_sentences` | Converts `false` to `'0'` and `true` to `'1'` | `non_splitting_tags` | Converts arrays to strings joining by commas | `ignore_tags` | Converts arrays to strings joining by commas -### Usage +### Monitor usage To check current API usage, use: ```rb usage = DeepL.usage