Google Cloud Translation Fails with "Too many segments" Error
written-by
Daniel Carrillo Broeder
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
legacy-article
learn-legacy-article-disclaimer-text
Issue
- When attempting to use the automatic translation feature for an entire page o contents with multiple fields, the process fails.
- The logs show the following error:
com.google.cloud.translate.TranslateException: Too many text segments
...
Number of text queries: <NUM> Maximum: 128
Environment
- Google Cloud Translation enabled.
- Liferay 7.4 and Quarterly Releases
Resolution
- The error is caused by a limitation in the Google Translate API, which Liferay's automatic translation feature uses.
- The API has a maximum limit of 128 text segments (fields) that can be sent in a single translation request. If a page contains more than 128 translatable fields (e.g., from multiple fragments with several editable sections), the API will reject the request, causing the translation to fail.
- This is a known limitation of the product's integration with the Google Cloud Translation API. A feature request has been created to address this in a future version.
- Until a permanent solution is implemented, consider the following workarounds:
- Translate pages in smaller sections rather than translating the entire page at once.
- Translate individual fields manually.
- For complex pages, extract some content into separate assets (like Web Content Articles), translate those assets individually, and then display them on the main page.
- You should open a support ticket to check on the status of the feature request LPD-58932.
did-this-article-resolve-your-issue