increase max character limit to 50000

Created on 10 March 2023, almost 2 years ago
Updated 26 April 2023, over 1 year ago

The module is hardcoded to a max character limit for translations of 5000.

However, if we look at https://learn.microsoft.com/en-us/azure/cognitive-services/translator/re..., we can see the actual max character limit for translations is 50,000.

I'm not sure if 5000 is a typo in the module, or if Microsoft's original limit was 5000 chars.

In any case, submitting a patch which increases the module's hardcoded limit to 50,000. I tested this with a 26,000 character translation and it worked without issue. Then, just to confirm that that the 50,000 Microsoft limit really is that, I increased the limit 100,000 in the module, and tried submitting a 52,000 character translation, and, as expected it fails. In other words, the 50,000 limit stated in the Microsoft documentation is correct. And the patch I'm submitting increases the limit to just that.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇦Canada Shiraz Dindar Sooke, BC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Shiraz Dindar
  • Assigned to urvashi_vora
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Hi @Shiraz,

    Since, you provided a patch, I am setting the issue status as 'Needs Review'.

    Also, I am assigning it to myself for reviewing your patch.

    Will provide the feedback soon.

    Thanks

  • Status changed to Needs work almost 2 years ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Hi @Shiraz,

    Your patch failed to apply.

    Moving the issue status to Needs Work.

    Although, the work you did is correct, but probably because of some pushes to the repository, the code changed a bit.

    If, I have to explain this further:
    Your patch contains-

    -  protected $maxCharacters = 5000;
    +  protected $maxCharacters = 50000;
     
       <strong>/**
        * Guzzle HTTP client.</strong>

    Where as, in recent code,

    -  protected $maxCharacters = 5000;
    +  protected $maxCharacters = 50000;
     
      <strong> /**
        * {@inheritdoc}</strong>

    It is like this.

    Your patch is failing here,

    Checking patch src/Plugin/tmgmt/Translator/MicrosoftTranslator.php...
    error: while searching for:
       *
       * @see https://docs.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-translate?tabs=curl#request-body
       */
      protected $maxCharacters = 5000;
    
      /**
       * Guzzle HTTP client.
    
    error: patch failed: src/Plugin/tmgmt/Translator/MicrosoftTranslator.php:43
    error: src/Plugin/tmgmt/Translator/MicrosoftTranslator.php: patch does not apply

    Because there is no

    /**
       * Guzzle HTTP client.

    After the "protected $maxCharacters = 5000;" in current code.

    I am keeping this assigned to myself, and will provide a patch.

    Thanks

  • 🇨🇦Canada Shiraz Dindar Sooke, BC

    Oh thanks so much. Yes, I did this on the stable release not the dev release, as we were hoping we could stick on stable, but if it's changed to the point where it needs to be on dev release, we'll switch. Thanks for looking at this!

  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Here is the patch.

    Please review.

    Thanks

  • 🇨🇦Canada Shiraz Dindar Sooke, BC

    Thank you! I can confirm that patch applies correctly on the dev release.

    Not sure if you want to wait for others or not to commit.

  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    If, you have reviewed this, we could probably move it to RTBC and I can commit.

    What is your opinion on this?

  • 🇨🇦Canada Shiraz Dindar Sooke, BC

    My opinion is it's a very simple change code-wise so there's no concern there. The bigger question is does it work, and in my tests, it did. Ideally someone else would test with a translation greater than 5000 characters to confirm, but it did work for me, and as far I personally am concerned, I'd like to see it get committed, but there's no rush. I'm not sure how actively used this module is -- in fact I was surprised to have someone reply so quickly (thank you).

  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    So, IMHO we must wait for someone else to test it thoroughly and if everything goes well, we will have this committed.

    Thanks for the quick responses. I highly appreciate it.

    Have a great day ahead.

  • 🇨🇦Canada Shiraz Dindar Sooke, BC

    Agreed. And, my day has just ended! Warm wishes from Canada!

  • Status changed to RTBC over 1 year ago
  • Status changed to Fixed over 1 year ago
  • 🇨🇦Canada Shiraz Dindar Sooke, BC

    Thank you!

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024