title: SWIFT Translator App
body: <p>I create translator using Yandex api.
  I use this function:</p>
  
  <pre><code>func getTranslate(text: String, lang: String, completion: @escaping (Translation?) -&gt; Void) {
      guard let url = URL(string: translateUrl + "?key=\(key)&amp;text=\(text)&amp;lang=\(lang)&amp;format=plain&amp;options=1") else { return }
      var request = URLRequest(url: url)
      request.httpMethod = "POST"
  
      URLSession.shared.dataTask(with: request) { (data, response, error) in
          if let error = error {
              print(error.localizedDescription)
              completion(nil)
              return
          }
  
          guard let data = data else {
              completion(nil)
              return
          }
  
          do {
              let translation = try JSONDecoder().decode(Translation.self, from: data)
              completion(translation)
          } catch {
              print(error)
              completion(nil)
          }
          }.resume()
  }
  </code></pre>
  
  <p>But if I enter in "Text" more one word translation is not carried out. </p>
  
  <p>The API documentation says:</p>
  
  <p>"For the source code, be sure to use URL-encoding."</p>
  
  <p>I suspect that my problem is related to the fact that I just use the text, not coding it in any way.
  How can this problem be solved?</p>
  
  <p>api documentation
  <a href="https://tech.yandex.ru/translate/doc/dg/reference/detect-docpage/" rel="nofollow noreferrer">https://tech.yandex.ru/translate/doc/dg/reference/detect-docpage/</a></p>