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
Reply
  • 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
Children
  • Hi Madalina,

    Here is a typical language property file with key value pairs that includes an element that does not contain a value:

    UNKNOWN=
    NEW=New
    UPDATE=Update
    DELETE=Delete

    When this language property file is parsed into into an array, the values are ["", "New", "Update", "Delete"] , which as you have noted throws an error when the data object is posted to the API. I suspected this might be an anomaly of the API, so I attempted to introduce a unique value into the blank, prior to posting, (i.e. ["BLANK TRANSLATION VALUE", "New", "Update", "Delete"] ), then use the Dictionary to replace BLANK TRANSLATION VALUE with BLANK TRANSLATION VALUE, and then replace BLANK TRANSLATION VALUE in the API response with a blank field in the language property file. Unfortunately, the Dictionary function isn't working for me and I have another support question that is trying to resolve that issue.

    I would be open to any suggestion you may have.

    Thanks,

    Chris

    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
  • 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]
  • Sending a character placeholder and dictionary to accommodate the LanguageWeaver API's inability to handle blank or empty input values was an attempt to find a work around. I may have found a better solution by sending escaped quotes (i.e., "\"\"") when a blank field is present on the outgoing translation request. Although not perfect, it does seem to be a little cleaner than trying to parse a unique character string. More testing needs to be done to verify this proposed plan unless you can offer a better way to handle blank values.

    emoji
  • Hello Chris, 

    Apologies for the late response. Sending escaped characters may work fine for majority of language pairs but for some language pairs the quotes may be specific to that type of language (e.g. you will get back these types of quotes « » when you translate the escaped quotes from English to French).

    One option you could explore is to set up a unique value (e.g. "BLANK_TRANSLATION_VALUE" or a different string that is unlikely to occur in translation) as a Brand entry. The advantage of the brand is that any brand entry you configure will remain untranslated across all the target languages you translate into, there is no query parameter to add to your api calls as this is a global setting.

    To set-up a Brand, as an Admin, you need to go "Settings > Brands > Create Brand > input the brand you'd like to set-up in the "Brand" field then click on  Create Brand (the "Comment" field is optional and "Is Seach Pattern" should be ticked only if you set-up a regex-based brand - not applicable for this particular situation).

    Look forward to your feedback if this is likely to give you an acceptable solution for your workflow.

     

    Thank you,

    Madalina

    emoji