Comments (14)
$result = $t->translate('html string here');
$result_with_correct_html = preg_replace('/\/\s/', '/', $result);
That's it.
from google-translate-php.
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.
You should do it with regex as the space is after /
.
from google-translate-php.
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.
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.
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.
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.
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
.google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php
Lines 55 to 68 in b11ae50
—
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.
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.
Can you make autoload versions ?. There i using hosting. Not supported for installing new php library
from google-translate-php.
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:
Can anybody check if some parameters are missing in this library?
from google-translate-php.
Please help me regex replace: class = "row" => class="row"
from google-translate-php.
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.
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)
- Very slow HOT 1
- Country an cities sometimes are not translated HOT 4
- ErrorException: Maximum execution time of 60 seconds exceeded HOT 4
- Class "Stichoza\GoogleTranslate\GoogleTranslate" not found HOT 1
- How do I swap to using my own paid api key? HOT 1
- Loading Problem. HOT 2
- I use the IP of a VPN server as a proxy, I wonder why it doesn't work when I use 'https' instead? HOT 5
- Can you give me a list of free Proxies that I can use so that translation is not blocked in the future? HOT 1
- Can you fix this bug in your library for me?
- 400 Bad Request Client error: GET HOT 5
- Can you add the link of my package to your package? HOT 1
- Ignore escaped keys on translations HOT 4
- Error: Class "Stichoza\GoogleTranslate\GoogleTranslate" not found in file HOT 6
- Bug report: preserveParameters gives unexpected results when translating to French HOT 1
- cURL error 60: SSL certificate problem HOT 1
- Please assist me HOT 3
- How can I translate my page web HTML into your library? HOT 2
- PHP - extract the children from this <div id="page-container"> then translate it and put them back into this same <div id="page-container">
- library is throwing TranslationRequestException
- bump ver HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-translate-php.