Git Product home page Git Product logo

Comments (6)

Stichoza avatar Stichoza commented on July 22, 2024

Yes, the array translation is broken and that's why the CI build badge is red :(

from google-translate-php.

armantsh avatar armantsh commented on July 22, 2024

The solution I have found for this, that is more or less accurate, is to implode texts with " \r\n ", and then call the translate on this string. After you can use explode(PHP_EOL, $results); to get translations. There is also some limitation for string length, that is why I am sending text which length is no more then 2000. So in case you have 8000 characters, you should call translate function 4 or 5 times. This is not very accurate, but it is something at least.

from google-translate-php.

tomvo avatar tomvo commented on July 22, 2024

@Stichoza yeah i've seen that the issue is with the array nesting level. But the solution seems too simple just to change the nesting level, right?

But there are two issues here, when I check the result of the getResponse() method on a multi-sentence translation it only returns one translation:

[[["Katze","cat",,,2]],,"en"]

I'm not sure how it has worked in the past but when I look at the request I see that the individual sentences are passed in using the same param name:

q=cat&q=dog&q=fish

Did it work like this in the past too without providing either an array of q's like q[] or a different body?

from google-translate-php.

untoreh avatar untoreh commented on July 22, 2024

@armantsh iirc \r\n still made the response make arbitrary strings relocation, the string I have come to use for like 2 months and has not afaik given me problems is \nΒΆ\n, the paragraph symbol should make sure no context is shared between lines.

from google-translate-php.

geoffreyc avatar geoffreyc commented on July 22, 2024

Fixed in this PR:

#88

from google-translate-php.

Stichoza avatar Stichoza commented on July 22, 2024

Array translation is removed in v4.0.0. You can either implode the array with new lines as @geoffreyc suggested, or just loop translate method.

from google-translate-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.