Git Product home page Git Product logo

Comments (14)

Stichoza avatar Stichoza commented on July 22, 2024 4
$result = $t->translate('html string here');
$result_with_correct_html = preg_replace('/\/\s/', '/', $result);

That's it.

from google-translate-php.

Stichoza avatar Stichoza commented on July 22, 2024

Yes, this is a problem with Google Translate itself.

I guess you can write a regex (or just str_replace) to replace < / with </ (without space). But anyways, do not depend on "hacks" like that.

from google-translate-php.

Stichoza avatar Stichoza commented on July 22, 2024

You should do it with regex as the space is after /.

from google-translate-php.

stewardjornsen avatar stewardjornsen commented on July 22, 2024

Any examples? It really misses up everything...

On Thu, May 14, 2015 at 8:03 PM, Levan Velijanashvili <
[email protected]> wrote:

You should do it with regex as the space is after /.


Reply to this email directly or view it on GitHub
#23 (comment)
.

Steward Godwin Jornsen
+234.803.9468.290
StewardXpress Nigeria Limited
www.stewardxpress.com

In His Name Bible Church
www.inhisnamebiblechurch.com http://www.ihnbc.com

This mail should only be used for the purpose of which it was sent and by
the receiver of this mail only. We guarantee that this mail is sent free of
all viruses or spyware. You are advised to scan attachments before opening.
StewardXpress/In His Name Bible Church is not responsible for how you used
the provided data.

from google-translate-php.

stewardjornsen avatar stewardjornsen commented on July 22, 2024

Thank you very much. I shall give that a try. If that works great, you
could as well extend the class to have that html return object. That could
be cool, don't you think?

Thanks again.

On Wed, May 20, 2015 at 11:00 AM, Levan Velijanashvili <
[email protected]> wrote:

$result = $t->translate('html string here');$result_with_correct_html = preg_replace('//\s/', '/', $result);

That's it.


Reply to this email directly or view it on GitHub
#23 (comment)
.

Steward Godwin Jornsen
+234.803.9468.290
StewardXpress Nigeria Limited
www.stewardxpress.com

In His Name Bible Church
www.inhisnamebiblechurch.com http://www.ihnbc.com

This mail should only be used for the purpose of which it was sent and by
the receiver of this mail only. We guarantee that this mail is sent free of
all viruses or spyware. You are advised to scan attachments before opening.
StewardXpress/In His Name Bible Church is not responsible for how you used
the provided data.

from google-translate-php.

Stichoza avatar Stichoza commented on July 22, 2024

I really appreciate your idea, but I don't think so. This package has a very simple API - just three methods and that's it. This is not intended to translate HTML strings. If so, then why not add JSON or XML support? It will lead to very impure code. Bringing back HTML tags is one simple regex (noted above). It's not worth adding extra functionality for that. Plus, I'm not sure this regex will fix all problems with translated HTML.

P.S I won't close this issue for now. Let it be open for further public discussions.

from google-translate-php.

Stichoza avatar Stichoza commented on July 22, 2024

The official paid API has format attribute where you can set that translated text is HTML.

So if we could find any way* to make it work with HTML strings without damaging tags and avoiding usage of extra "hacky" regexes, it would be really cool.

* - Maybe it can be achieved using some attribute in URL string. The actual translate.google.com doesn't have option to set type to HTML, so I'm not sure we can find an easy solution for this

from google-translate-php.

stewardjornsen avatar stewardjornsen commented on July 22, 2024

Thanks,
No point anyway. Google sometimes translates the names of classes and Tag
ID which does seriously scramble website functionality.

Steward

On Thu, May 21, 2015 at 1:01 AM, Levan Velijanashvili <
[email protected]> wrote:

The official paid API has format attribute
https://cloud.google.com/translate/v2/using_rest#query-params where you
can set that translated text is HTML.

So if we could find any way* to make it work with HTML strings without
damaging tags and avoiding usage of extra "hacky" regexes, it would be
really cool.

* - Maybe it can be achieved using some attribute in URL string

'client' => 't',
'text' => null, // String
'hl' => 'en',
'sl' => null, // Source language
'tl' => null, // Target language
'ie' => 'UTF-8', // Input encoding
'oe' => 'UTF-8', // Output encoding
'multires' => '1',
'otf' => '0',
'pc' => '1',
'trs' => '1',
'ssel' => '0',
'tsel' => '0',
'sc' => '1'
.


Reply to this email directly or view it on GitHub
#23 (comment)
.

Steward Godwin Jornsen
+234.803.9468.290
StewardXpress Nigeria Limited
www.stewardxpress.com

In His Name Bible Church
www.inhisnamebiblechurch.com http://www.ihnbc.com

This mail should only be used for the purpose of which it was sent and by
the receiver of this mail only. We guarantee that this mail is sent free of
all viruses or spyware. You are advised to scan attachments before opening.
StewardXpress/In His Name Bible Church is not responsible for how you used
the provided data.

from google-translate-php.

Stichoza avatar Stichoza commented on July 22, 2024

That's exactly what I mean "without damaging tags". Yea, I think there's no way to translate HTML using this service url.

from google-translate-php.

dimaslanjaka avatar dimaslanjaka commented on July 22, 2024

Can you make autoload versions ?. There i using hosting. Not supported for installing new php library

from google-translate-php.

vielhuber avatar vielhuber commented on July 22, 2024

The official API has way better support for html tags. When reverse engineering the current inline translation of Google Chrome, these results are also very good (and with correct html tags).

I've extracted the following parameters, Google Chrome currently uses:

image

Can anybody check if some parameters are missing in this library?

from google-translate-php.

thanhansoft avatar thanhansoft commented on July 22, 2024

Please help me regex replace: class = "row" => class="row"

from google-translate-php.

RokonuzzamanJhinuk avatar RokonuzzamanJhinuk commented on July 22, 2024

bro you can use this to translate your html database data to any language using this package.
just use like this---- First decode the html code.. then use inside this package translate function.

{!! \Stichoza\GoogleTranslate\TranslateClient::translate( Session::get('s_lang'), Session::get('t_lang'), html_entity_decode(str_limit($n->body,500) ) ) !!}

from google-translate-php.

milahu avatar milahu commented on July 22, 2024

The official paid API has format attribute where you can set that translated text is HTML.

the paid API also allows <div class="notranslate">...</div> to disable translation for specific terms

So if we could find any way* to make it work with HTML strings without damaging tags and avoiding usage of extra "hacky" regexes, it would be really cool.

* - Maybe it can be achieved using some attribute in URL string. The actual translate.google.com doesn't have option to set type to HTML, so I'm not sure we can find an easy solution for this

yes, it was not easy ^^ but i got it working in my translate.js script
also see my post in Prohibit the translation of pieces of text in Google Translate

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.