04-13-2023 07:01 AM
if for example I need to translate this text :
this is the "as is system" text
The API return an error if I try to use escaped double quotes. And the API don't accept markups (I have tried to substitute double quotes with the markup but I receive an error message)
The only solution I have found is to remove double quotes from the text
Any idea ?
04-13-2023 10:15 AM
Specifics on what language/api/tools and what field you are trying to get working would help as this is kind of contextual to those things.
04-13-2023 11:27 AM
I use api translate and the issue appears if the text to be translate contains double quotes
commerce/translation/v1_beta/translate
This appears in every language from an to
04-13-2023 11:51 AM
My apologies, I forgot about the Translate API.
Still likely language specific, have you tried double escaping?
in python I get the response of:
b'{"from":"en","to":"es","translations":[{"originalText":"hello this \\"is an\\" item","translatedText":"hola este art\xc3\xadculo \\"\\"es un\\"\\""}]}'
for a payload of:
python code:
json = {
"from" : "en",
"text" : [
"hello this \"is an\" item"
],
"to" : "es",
"translationContext" : "ITEM_DESCRIPTION"
}
Same result if I use ITEM_TITLE as well.
04-13-2023 12:08 PM
Additional note: without quotes I am getting 2 different results for ITEM_TITLE and ITEM_DESCRIPTION:
ITEM_TITLE
b'{"from":"en","to":"es","translations":[{"originalText":"hello this is an item","translatedText":"hola this is a item"}]}'
ITEM_DESCRIPTION
b'{"from":"en","to":"es","translations":[{"originalText":"hello this is an item","translatedText":"hola este es un art\xc3\xadculo"}]}
It is a beta and I don't see any in depth detailed documented guidelines on how it is intended to be used, but note that "text" : [ ] is an array of strings. -- It appears when using ITEM_TITLE that whatever systems the server is using splits the string and operates only on the first element (strings are arrays, different languages handle things differently, this is a common python issue when you don't use a trailing comma on a set, but json forbids trailing commas, so you end up with potentially unexpected behavior if that isn't accounted for).
You will likely have to play with it a bit to get the behavior you want.
04-13-2023 12:10 PM
To clarify language specific, i mean programming language.