Blank values sending data to the API

When I use the API to send an array of strings to translate, some of the values are blank (i.e. contain no value). This appears to throw a translation error. However using the Portal blank values are accepted. How can I translate an input with empty values (i.e., "one", "two", "", "three")

emoji
Parents
  • Hello Chris,

     

    You are indeed receiving that error message via the API because one of the elements in the array is empty. The reason it works in the UI is because it uses a different type of submission/input format, it treats the text you put in the UI as a full string, not an array of elements.

    Can you please provide more details on your use case and requirements either via this post or I can reach out by email with some proposed timings and we can have a quick sync.

     

    Look forward to your feedback.

     

    Thank you,

    Madalina

    emoji
  • A follow-up regarding my proposed solution to use a dictionary and BLANK TRANSLATION VALUE to address a blank. As I've noted in (+) Dictionary is not in drop down - Forum - Language Weaver - RWS Community I'm able to use a dictionary that contains BLANK TRANSLATION VALUE. Using the web portal I can enter:

    BLANK TRANSLATION VALUE
    New
    Update
    Delete

    and Indeed, BLANK TRANSLATION VALUE is not translated and is returned to the portal ui with the value specified in the dictionary.

    However, if I include the dictionary ID in my API translation request, the Language Weaver API translates the dictionary value and not the text specified in the dictionary. If I contort the return value with special characters and numbers (i.e., NO_1 TEXT_2 HERE_3) the response I get from the API will return NO_1 TEXT_2 HERE_3.

    Is there something I'm not aware of when using a dictionary ID with an API translation request?

    emoji
Reply Children
  • Hello Chris, 

    Could you check how you are passing the dictionaries request parameter and if similar to the below? The "dictionaries" request parameter is a a string array containing dictionary ids. You will need to specify the ID of the dictionary you have set-up.

    "dictionaries":["dictionaryID"]
    To retrieve the "dictionaryID" from the Language Weaver UI, go to the Dictionary page, click on the dictionary name that you have set-up, then click on "Show details". The dictionary ID will be displayed and you can copy it.
    I believe you are using our Postman collection, but in case you are not, I am sharing here the link for reference: https://developers.languageweaver.com/developer-tools/postman-collection/lw/index.html
    I hope this helps. Look forward to your feedback.
    Kind regards,
    Madalina
    emoji
  • I use Postman regularly, however I've not configured it to use our proxy. That said, I've developed a Java SpringBoot application which communicates  with the LanguageWeaver API, posting the following Translation Request attributes:

      private String sourceLanguageId;
      private String targetLanguageId;
      private String model;
      private String submissionType;
      private String inputFormat;
      private String[] input;
      private String[] dictionaries;
      private String translationMode;
      private String linguisticOptions;
      private int qualityEstimation;
      private String requestId;
    In this context, the dictionaryID, copied from the "Do Not Translate" id. , is passed to this object which a post request sends this to the LanguageWeaver api. Since I do get a response with translated data, and the not translate variable I've configured using NO_1 TEXT_2 HERE_3, I'm confident the dictionaryId is being transmitted.
    I suppose I could try to configure Postman, but would rather work with my source code. 
    Is this sufficient to diagnose this issue?
    Screenshot of Language Weaver's 'Do Not Translate' dictionary settings page showing a term with source 'BLANK TRANSLATION VALUE' and target 'NO_1 TEXT_2 HERE_3' with a comment 'test case'.
    emoji


    Generated Image Alt-Text
    [edited by: RWS Community AI at 4:14 PM (GMT 1) on 1 Oct 2024]