Dynamic Localization on the fly - c#

I have strings that admin user can input into database.
User can select language, I want to localize this text according to it.
I do not want translate strings as I want to keep semantics same.
Also I have researched but I have found examples for only static strings.
Below question is relevant but I do not know string at compile time.
User can insert any string.
Relevant stackoverflow question

If I understand your question correctly, there is no easy way to do this.
All UI localization tools are concerned with localizing texts stored in your application, like the text on a button, or an error message.
If your application shows texts from a database, this a completely different problem.
Normally, you would have to allow for a multilingual text in your database schema and give your admin user a way to enter a localized text. Probably, you would have to define a translations table with
the original text (or a text ID)
a language ID
the localized text
In your application you would have to fetch the localized text from translations table.
If you use the original text as the key into the translations table, you will not have to modify the original table. If you use an ID, you would need to store this ID in the original table. Both have pros and cons.
If you are not too worried about the quality and consistency of the translations, you could use an online translation service. There are APIs for both the Google and Bing translator. Technically they are both paid services, but - at least with Bing - I think you have to pass a monthly threshold before they actually charge you anything.

Related

Hanlding Dynamic multi-lingual content in ASP.NET (Roman, Hindi & Urdu)

I want to create a website in ASP.NET which handles multiple languages. My content is in three languages: Roman, Urdu and English.The content will be dynamic.
For example, if a user visits my website and he searches on website for a specific post. Then the user wants to change the language preference, its content will change dynamically as a user selects different language from menu. Then he searches for another post and wants to change language preference to some other language, the content must be translated again into the newly selected language.
I can afford to insert separate data for each of the language in database but i am not sure if this works and how this works (how to create db design for such solution and how to store and retrieve same data in multiple languages in db).
I have been looking at some threads on different platforms but the solutions I have come across with are not feasible for my scenario.
One solution is to use Google Translate, but I need quality translation and Google Translate does not perform well on Roman Language.
Another most encouraged solution for ASP.NET is to use resource files (key-value pairs for content). Using Resource files for small websites where content is static works perfectly fine, but the resource files are not salable and would not work for my scenario as the content I am dealing with is completely dynamic.
Please let me know if there is a solution. Any help will be appreciated!
Thanks.

input certain textfield text and display it on the web page

I am trying to make an web based "configuration" tool that will contain a lot of Cisco configuration templates for switches and routers.
But since I am new to C# I have some questions. Just so you know I am already familiar with basic strings etc... and I also have VS 2013 up and running.
This is not so relevant in this question, but just so I have mentioned it, I am using ASP.NET MVC (with C# as prog. language) and I am quite familiar with ASP.NET MVC.
Now here is the question, lets say this is anCisco` switch template config:
interface eth102/1/1
description test-server
switchport mode trunk
switchport trunk allowed vlan 100, 200
no shut
So what I am trying to do is to give the users an option to add following
text fields:
ALLOWED VLAN: xxx
DESCRIPTION: xxx
Which means user types in VLAN ID and description for example, and then when he click on "submit" button or "get config" button name, then the user should get the complete template config listed somewhere on the page..
including the VLAN id and description that user typed in.
My question is, is it better to hard code template configurations or use an SQL DB?
As a rule of thumb: hard coding is never a good stategy unless you are very certain, that the hard coded text is correct and will never change. If you have to change it you will have to recompile your app.
If you don't want to use a db that at least read your text from file. That way you can change or extend your text easily. Maybe consider implementing text tokens, that will be replaced by your app. That way you are more flexible because you won't have to rely on keywords in the text...

C# application to read in and translate other applications

I am trying to build a Translation Assistant which can read in other compiled C# application (.exe), and display the forms from the EXE, are displayed individually, along with a table next to it with english column which will show the current english words on display, and another column for the value, which a translator can enter. Once completed translations, the translator can export the translations a resx file, to add to a project and also as an excel file for record purposes.
I am new to C# and hence am not sure if my strucute is correct, i have designed in such that a dll is inserted into the .exe during compilator, and then using this dll, the translation application can extract the string. This works for most strings, but it is getting stuck where there are several string that can apear in the same textbox at different times [e.g. disconnected, connected etc]. I have tried searching everywhere, but I am not able to find information on how i will be able to pull out all strings from an application, and be able to identify which form they belong to, in order to create my application?
the other issue i am faced with is, actually displaying the translated strings, the application i am building would benifit greatly if it could display a example of how the translated strings would look, as translations in some languages could be excessivly long. but i have found that i am only able to read in the aspects of the compiled applications and create an instance, but am not able to translate it.
I am reading in the exe using Reflection, and have understood from online that i need to use reflection.emit to modify the form. but i am finding every sting that is idenfitied from the form, is extracted as an instance, hence changing the string is only changing the instance of the strings , and not the instance of the form itself. hence i am not able so a correct display.
I have been trying for 3 weeks to solve these last two questions, Thanks in advance for helping me solve this.
I think you can't find a general solution to your problem with the texts that may appear in the textbox. Here is why:
If the texts are in the resource file, you could read them, but you still don't know where they are used. You would need to do a complex analysis of the source code to know, where the text is displayed. Just imagine this little scenario:
textBox.Text = GetCorrectText(connection.State);
GetCorrectText could look like this:
string GetCorrectText(ConnectionState state)
{
return string.Format(Resources.ConnectionState, state);
}
Resources.ConnectionState might be "The connection is in the state {0}".
Its a simple example, but you would need to know or extract a lot of things:
The text property of the TextBox class is the string that is shown to the user
The Method GetCorrectText returns the text, so you need to parse it.
The Method string.Format returns the text. Now you either would need to hardcode that for string.Format it should use the first parameter as the text that is displayed or you would have to parse string.Format to learn that fact.
The example shows something else: You wouldn't be able to translate the whole string that is being displayed, because part of it is the name of the enum value.
What I want to show you is that you need to make trade offs.

Reading Character from Image

I am working on an application which requires matching of numbers from a scanned image file to database entry and update the database with the match result.
Say I have image- employee1.jpg. This image will have two two handwritten entries - Employee number and the amount to be paid to the employee. I have to read the employee number from the image and query the database for the that number, update the employee with the amount to be paid as got from the image. Both the employee number and amount to be paid are written inside two boxes at a specified place on the image.
Is there any way to automate this. Basically I want a solution in .net using c#. I know this can be done using artificial neural networks.
Any ideas would be much appreciated.
You can use Microsoft Office Document Imaging Library (MODI), which is contained in the Office 2003/2007.
Links:
OCR with Microsoft® Office - Code
Project - example of using MODI
Microsoft Office Document Imaging -
Wikipedia - contains a simple
example in VB.NET
Pattern recognition is a basic example when neural networks are studied. I don't know if is any library/framework to work with AI in C#. If you find one, first you have to do is to train the network (supervised learning) and for this you need to prepare a big sample set of images; more examples -> result more accurate. In the other hand you can use OpenCV (C/C++, Python and Java) that is a library specialized in computer vision and has a module to implement AI methods.
Have a nice day!
Oscar.
I think this is very hard to automate. The problem is just because you need some kind of very good OCR software. And even if you got this, what if it reads something wrong, cause of the frouzy handwriting of someone? If the ID is wrong the paid is booked to the wrong employee and if the amount is wrong he got the wrong salary!
Both are things you won't really happen. Just to show you how hard a good ocr to find is, just take a look out there on how a captcha works. The principle is nothing more than an image of an hard to read text.
So my opinion would be, that you can't really automate this process. At least you can write a program to assist a human by entering the values manually (also take a look at Amazon Mechanical Turk):
Show on the right the picture with the handwritten values, or if they are always on the same position or specially marked (with a box around them, etc.), try to find these places automatically and show them to the user.
On the left offer two textboxes, where the user can enter the values.
To get this to a fast and fluent process, you have to take great care about how the user can enter easily the values by just using the keyboard:
When showing a new picture, set the focus to the id textbox
If the user id is always a specific length, switch to the next box if all numbers are entered
(If you allow this, a backspace in the empty next box should focus back to the previous one)
Otherwise allow a change to the next textbox by hitting tab or return
Normally these textboxes are arranged above each other (not side by side), thus you should support switching between them using the up down arrow keys.
After finishing the entry in the last textbox automatically show the next image.
Also in this case of a fresh new entry (nothing already entered) allow a easy switch back to the old entry by using the backspace or left arrow key)
By using such a process a single person can enter many entries into your database and the costs are much cheaper than finding wrong entries in your database afterwards.
Just a last suggestion:
Cause this is a boring process for a human which can easily leads to errors, maybe let two people enter these values and only if both are entering the same than take this value as approved. This should lead to a correct rate somewhere above 99%. If you need absolutely 100% think about letting 4-5 people checking one entry and only if all of them enter the same values take it as approved. To get also a comparsion about how good your ocr software would be, just let it also run over your images and compare this results to the human entered values to get an idea, when you can really rely on your ocr only.
OCR engines are not trained to read handwritten text, so you might have trouble with MODI. You want to try to find an ICR engine. Even so, the best ones of these are only 80% accurate on good inputs. You might get better because you know that your text is always numbers.
This SO question/answer says that OCROpus has ICR
FOSS Intelligent Character Recognition (ICR)
There is LeadTools SDK for OCR/ICR. This is very handy in recognising the handwritten characters. I am doing a feasibilty study with this, and till now I think it will work out. leadTools have provided components which can be used in your application, it supports C, C++, C#, VB.Net etc.
You can visit the following link for this:
http://www.leadtools.com/downloads/default.htm?category=

Compare the textual content of websites

I'm experimenting a bit with textual comparison/basic plagiarism detection, and want to try this on a website-to-website basis. However, I'm a bit stuck in finding a proper way to process the text.
How would you process and compare the content of two websites for plagiarism?
I'm thinking something like this pseudo-code:
// extract text
foreach website in websites
crawl website - store structure so pages are only scanned once
extract text blocks from all pages - store this is in list
// compare
foreach text in website1.textlist
compare with all text in website2.textlist
I realize that this solution could very quickly accumulate a lot of data, so it might only be possible to make it work with very small websites.
I haven't decided on the actual text comparison algorithm yet, but right now I'm more interested in getting the actual process algorithm working first.
I'm thinking it would be a good idea to extract all text as individual text pieces (from paragraphs, tables, headers and so on), as text can move around on pages.
I'm implementing this in C# (maybe ASP.NET).
I'm very interested in any input or advice you might have, so please shoot! :)
My approach to this problem would be to google for specific, fairly unique blocks of text whose copyright you are trying to protect.
Having said that, if you want to build your own solution, here are some comments:
Respect robots.txt. If they have marked the site as do-not-crawl, chances are they are not trying to profit from your content anyway.
You will need to refresh the site structure you have stored from time-to-time as websites change.
You will need to properly separate text from HTML tags and JavaScript.
You will essentially need to do a full text search in the entire text of the page (with tags/Script removed) for the text you wish to protect. There are good, published algorithms for this.
You're probably going to be more interested in fragment detection. for example, lots of pages will have the word "home" on them and you don't care. But it's fairly unlikely very many pages will have exactly the same words on the entire page. So you probably want to compare and report on pages that have exct matches of length 4,5,6,7,8, etc words and counts for each length. Assign a score and weight them and if you exceed your "magic number" report the suspected xeroxers.
For C#, you can use the webBrowser() to get a page and fairly easily get its text. Sorry, no code sample handy to copy/paste but MSDN usually has pretty good samples.

Categories

Resources