I have developed a web application in java. Now I want to put translation facility without using any outside stuff like google translator.
I want to know if there are any libraries available for language translation from English to Hindi, French, Gujarati, etc ? Any alternative solutions?
The typical solution to this is to have your code look up all strings to be translated in a ResourceBundle, where you then manually enter translations for all languages supported.
Have a look at the internationalization section of the Sun Java Tutorial - http://docs.oracle.com/javase/tutorial/i18n/index.html
I think you can use the Google transalation API's. You can use the classes present in the API, from your java code.
Related
So, I'd like to create a bilingual program. From what I have heard, xml files are way to go...
I couldn't really find anything useful with Google (when you enter Java in Google it sees the word "language" only as in "programming", instead of desired "spoken"), so if any of you could direct me to some tutorial page which explains this topic further, or even show it to me here (It can be that complicated, can it?), I'd be very grateful.
If xml is way to go, that is! If any of you have any better suggestions, I'm listening...
XML could be the way to go, but the usual approach to internationalise your Java applications is using ResourceBundles. When asking Google the right keywords are: Java i18n or Java Internationalization.
There is a basic java tutorial that can get you started with i18n. If you are writing a web application then you should check the documentation of your specific framework.
Java has a built in internationalization system that uses properties files.
Java Internationalization API Tutorial
If I have implemented a Java Library (that offers certain functionality), could I transform this into a JavaScript library, such that the same functionality can be offered?
I know this may be an ask, but, I was wondering if there are frameworks existing that help in this?
No, in general this is not possible, Java and JavaScript are more or less completely different languages.
However there are a couple of Java to JavaScript translators that you can try. Java2Script is one such tool. Apparently the Google Web Toolkit (GWT) does this as well. Source.
While you could probably do some sort of conversion, it's important to note that Java and JavaScript, while similarly named, are not at all related. Unfortunately, I think you'll be hard pressed to find a framework or system that does a good job converting one to the other. :(
I'd like to learn GWT, and I like the fact that it compiles to Javascript. My question is, how much of Java I can really use with GWT? My guess would be that limitations apply mostly for client side, while on the server side I should be able to make use of any existing Java library, right? Or, will I be only able to use a small subset , because of the compilation to Javascript thing?
What are it's limitations? I am interested in what it's not able to do, or things that require too many workarounds to implement. I need to know if learning GWT is a good choice for a possible freelance carrier in web development.
The GWT website has this documentation exactly to answer that question.
See the JRE emulation docs. Those are the supported out of the box emulated classes that you can use.
"Google Web Toolkit includes a library that emulates a subset of the Java runtime library. The list below shows the set of JRE packages, types and methods that GWT can translate automatically. Note that in some cases, only a subset of methods is supported for a given type."
You can also provide your own emulation for other classes using <super-source/> in your gwt.xml to point to a package that will provide replacement Java classes for those that can't be directly compiled to JavaScript.
Is any way to convert a java applet code to java script?
Not really, no. They're different languages with different libraries.
If you want to develop for the client-side Web with Java, have a look at GWT
I don't think there is a good way to do so. Please remember: Java and JavaScript are two entirely different technologies. Don't mix them up.
Not directly and without effort as far as I know. However people have ported many things to HTML/JS, like Quake 2 on GWT. So you could invest some time and step into the code and port it with GWT.
Advantages of going with GWT arise from the fact that your applet is in Java language, which is the same language you use for GWT. Here is a list of what you can use in your code: GWT JRE Emulation
No.
Google Web Toolkit (GWT) is what you might need. I recommend book GWT In Practice 2008
12 years later there is now a tool called "JSweet" which claims to do exactly that: converting Java code to JavaScript: https://www.jsweet.org/
There is also a blog post from 2019 of someone using JSweet to convert some Java Applets to JavaScript: https://www.lprp.fr/2019/08/jsweet-convert-applets-to-javascript/
I am interested to create a drag-and-drop layout designer using only JavaScript, HTML and CSS. The designer will allow the user to drag the page elements from one place to another (something like Blogger's layout designer) to create a site layout. But I don't want to hand code everything in JavaScript, I would prefer to write my application in .NET (preferably) or Java and rely on a compiler to compile it to JavaScript and HTML.
What are the .NET or Java to JavaScript compilers that you have used and can recommend? For Java to JavaScript I know GWT is available. What about .NET to JavaScript? Microsoft did come out with Volta, but the project seems to be no longer available.
Look no further, you already mentioned GWT pick that!
It has a very good API and many good applications have use them.
Even JavaScript frameworks like http://extjs.com/ have GWT support.
I use it for an small JavaScript calendar recently.
To be honest, I don't really like JavaScript that much. Most of the times the errors are hard to track (specially for a non JavaScript guy as me) and the workarounds included some plug-ins for the explorer just to get exactly what a compiler should do. Catch silly error early.
In the other hand I'm very familiar with the Java Programming language, and many of the libraries (if not the most important) such as java.lang and java.util have been ported to GWT.
Plus, the guy who wrote relevant parts of java.util is the same behind GWT (google Joshua Bloch.)
Check out Nikhil Khotari's Script# project. It allows you to write C# code and compiles it to JavaScript.
Script# has already been mentioned. It hasn't been updated since August 2008.
Milescript is another, but also has seen very little for 6 months.
Extsharp for the Ext library. Adds Ext support for Script#
Javascript compiler to Java (going the wrong way for you)
Java to script Eclipse plugin
My issues with Script# (a known issue) is it doesn't support jQuery yet. However it comes with a very lightweight library to tie in with the .NET framework, in Nikhil's sscorlib.js file and ssfx.core.js files. And also has support for lots of other Javascript APIs (mostly Microsoft, seeing as he is in the ASP.NET team).
I'd love to see a Script# extension for jQuery (I'm thinking about writing it if it's easy enough). As it stands, most don't provide full compilation yet but they're certainly getting there.
Update: I wrote a small extension to enable JQuery support Script# a few months ago. The project can be found here.
I'm going to second the use of GWT. I've used it for several projects and, when used in combination with a modern editor like Eclipse or IDEA, it really makes the mess manageable.
It's important to note that not only does it allow you to write in Java and have that transformed into optimized and obfuscated Javascript it also comes with a substantial subset of the core Java API. In addition to this they provide lots of additional classes for doing things like parsing and working with JSON and XML and communicating with a server via asynchronous HTTP. You can check out the docs to get an idea of what else they offer.
Another feature that might be of special interest to you for implementing drag and drop functionality is it's integration with javascript libraries like Ext and scriptaculous. Either through pre-built interfaces or via JSNI
Also for Java there is J2S.
Java2Script (J2S) Pacemaker provides
an Eclipse Java to JavaScript compiler
plugin and an implementation of
JavaScript version of Eclipse Standard
Widget Toolkit (SWT) with other common
utilities, such as java.lang.* and
java.util.*. You can convert your
SWT-base Rich Client Platform (RCP)
into Rich Internet Application (RIA)
by Java2Script Pacemaker.
This means that if you use the SWT IDE (drag and drop) you can then convert the generated code to JS + HTML.
I wouldn't hand write any Javascript for UI. This can lead to maintenance disaster. jQuery is what I am using but I still wouldn't use it to write full UI Javascript code. ExtJS is also another good option if you plan to write in Javascript. In general what I am saying here is that it's so much easier to main in Java/C# than Javascript. Check out cappuccino framework and Atlas. Never used GWT. Script# is similar to GWT but for ASP.NET framework. Also depends on the requirement, if your site is public facing then RIA isn't a good option. It's all about which extreme end you pursuit (hand written and web standard, or RAD or libraries like jQuery/ExtJS as the middle option).
Check out Axial, a .NET to JavaScript converter that works well in ASP.NET. It supports WebForms, jQuery and canvas. It's not very mature, but it's worth a look.
http://jsc.sourceforge.net/ is a C# to JavaScript, Java, Flash and PHP compiler.
JscriptSuite offers another free .NET to Javascript compiler. There is a big difference to Saltarelle (jsc, SharpKit# etc.). Developer write down and debug only C# code (or any other .NET langauge), like in GWT. Javascript will be generated für deployment only.