I have written an API that translates text from english to Hindi language. However, if the text that is passed is an html text, then my code fails.
How do I get this right?
I have tried using py-translate, but this package is not able to convert html texts properly.
I have also tried using googleclient package, it is able to convert html text but can handle only one request at a time.
My API should be handle multiple requests and also be able to deal with html text translation.
Any help is appreciated.
Related
I used Summernote text editor to input data. But now all data come with HTML tags.
How can I get this data into plain text?
I solve the problem. My answer is given below:
I'm trying to convert a rich text on a TRichEdit component to HTML tags.I have a function for that, but it doesn't work because the text in the component is always sent on PlainText. The option PlainText on the component is set as false.
Example: *Text in RichEdit: The house is blue. When I invoke the function is sent without the bold format in the text: RTFtoHTML(RichEdit.Lines.Text).
How can I do on the component or in other side to read this text like RTF?
I have read other questions and it didn't solve my problem. Thanks for your help.
There are a few 3rd party commercial components that do this quite well such as WPTools or TRichView. Both will attempt to optimize the generated HTML using CSS styles where applicable. Both support Delphi 2010, as well as the latest version of the compiler (Delphi Seattle as of this answer).
In a smartphone app I receive HTML text from a server that I have to parse using regexes because I can't display it as HTML (I can't use a webview). The regexes are very intensive (are many) and the results (being the original text inserted by users that cut and paste text from any source, pdf, rtf, etc.) is not always as good as the website counterpart. So, I want to suggest my boss to change the format the mobile client receives, so that I don't have to parse HTML. Question is: what could be this format?
I have a form with a text field that users input text into. They can use multiple lines, put in bold text, underlined text, etc., but the text, when saved to SQL Server doesn't have any formatting saved, just the text is saved. What is the best way to save the text with the HTML so that when it gets viewed by another user and pulled up from Sql Server the HTML is saved and the formatting is saved?
Ex.
hello
Paul
This would be saved as
helloPaul
you can't see it but there are bold and carriage return html tags rapped around the text
When receiving data from the user, on the server side code, use HTML encode to safely store the data:
var inputData = Server.HtmlEncode("<strong>some data input from user</strong>"); //insert your user input data variable here
Then when displaying the data in your cshtml page, decode the data to display it as the user entered it:
HttpUtility.HtmlDecode(saveUserDataFromDatabaseVariable);
All this is assuming you have a rich text editor being plugged into the input field. CKEditor and TinyMCE are good ones.
You can use a text editor. Take a look at CKEditor. It's free and easy to use :)
Can you post some code and more details?
I have had good success with CKEditor. It is customizable, and its content can easily be saved via postback to a standard asp:TextBox.
It is possible that the editor you are using is not actually updating the input/textarea that you are using, it may be cloning the text and drawing the formatting in an overlay. You can use developer tools, or javascript, to verify this by checking the value property of the input or textarea element. If it is being saved via AJAX or javascript the code may be using the textContent or innerText properties instead of innerHTML.
I used the richtexteditor dll that's free online. it gave me a wiziwig box that the user can edit texxt in.
Does anybody know how to insert some formatted text string into some RTF file?
I am able to insert any plain text into an RTF file (to any place in document I want), but not formatted strings.
I know that when such string is added to RTF file, then also some RTF heading has to be updated. And here is a problem. I need to find out what shall be placed in RTF heading and in which exactly place. Maybe there is some ready solution. So far I cannot find it anywhere.
Normally I work with Java, but the problem is not necessary related to any language.
They talk about using a valid headder, in the .rtf specifications. I hope this will help you to get a valid format result.
Plain text in .rtf files, without any valid "formatting syntax", will not return any other result than the given plain text.
Another way, to get a neat rich text formatted document, is by using an .rtf editor or some .rtf compiler for the programming language you are using.
Instead of dealing with the rtf property, you can use the Text property. Set the cursor to where you want to insert text. Then paste formatted text from another richtext box, or paste normal text and change its formatting.