title: Cloud Translate API Java client - problems using source, target lang
body: <p>I have an issue here that I'm hoping to resolve. First, when I call the cloud Translate service with source and target languages, I encounter the following error:</p>
  
  <pre><code>java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
  at com.google.cloud.translate.TranslateImpl.optionMap(TranslateImpl.java:131)
  at com.google.cloud.translate.TranslateImpl.access$000(TranslateImpl.java:40)
  at com.google.cloud.translate.TranslateImpl$4.call(TranslateImpl.java:113)
  at com.google.cloud.translate.TranslateImpl$4.call(TranslateImpl.java:110)
  </code></pre>
  
  <p>This is what I'm doing:</p>
  
  <pre><code>protected Translate getTranslationServiceClient() throws IOException {
          if (translationServiceClient == null) {
              synchronized (this) {
                  if (translationServiceClient == null) {
  
                      try (InputStream is = new FileInputStream(new File(getCredentialFilePath()))) {
  
                          final GoogleCredentials myCredentials = GoogleCredentials.fromStream(is);
                          translationServiceClient = TranslateOptions.newBuilder().setCredentials(myCredentials).build().getService();
                      } catch (IOException ioe) {
                          throw new NuxeoException(ioe);
                      }
  
                  }
              }
          }
  
          return translationServiceClient;
      }
  
      public TranslationResponse translateText(String text, String sourceLanguage, String targetLanguage) throws IOException {
  
          Translation response = translationService.translate(text, TranslateOption.sourceLanguage("en"), TranslateOption.sourceLanguage("es"));
          //System.out.println(response.getTranslatedText());
          GoogleTranslationResponse gtr = new GoogleTranslationResponse(response);
  
          return gtr;
      }
  </code></pre>
  
  <p>The error points to the Cloud's TranslateImpl class optionMap method and spills the NoSuchMethodError on the checkArgument. Am I Passing the TranslateOption's incorrectly??:</p>
  
  <pre><code>private Map&lt;TranslateRpc.Option, ?&gt; optionMap(Option... options) {
  Map&lt;TranslateRpc.Option, Object&gt; optionMap = Maps.newEnumMap(TranslateRpc.Option.class);
  for (Option option : options) {
    Object prev = optionMap.put(option.getRpcOption(), option.getValue());
    checkArgument(prev == null, "Duplicate option %s", option);
  }
  return optionMap;
  </code></pre>
  
  <p>}</p>
  
  <p>In an effort to get any kind of response from the API, I've tried calling the service without passing any options or just the targetLanguage. Without any options, I don't have any errors and my texted is translated into english, as expected. If I just add TranslateOption.targetLanguage("es"), I still get the NoSuchMethodError.</p>