Index of /javascript/languid
Name Last modified Size Description
Parent Directory 25-Aug-2007 14:49 -
languid-1.0.tar.gz 17-Nov-2004 11:54 2k
NAME
languid.js - JavaScript interface to the languid.cantbedone.org API
SYNOPSIS
# you'll need to do this under Mozilla/Gecko (but not Safari)
# netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
# Get some chunk of text, for example a
# part of the current document.
var input = document.getElementById("input");
var txt = input.firstChild.nodeValue;
var lang = new Languid();
var ident = lang.identify(txt);
var result = null;
# My kingdom for a built-in sprintf function...
if (ident.success()) {
result = ident + " (" + ident.code() + ")";
}
else {
result = "error : " + ident.err() + ", " + ident.errstr();
}
# Set 'result' as the string value of some other
# part of the current document.
var languid = document.getElementById("languid");
languid.innerHTML = result;
DESCRIPTION
JavaScript interface to the languid.cantbedone.org API. This library is
not asynchronous.
Languid CLASS METHODS
new Languid ()
Returns a *Languid* object.
Languid OBJECT METHODS
obj.languid(String)
Returns an *Response* object.
Resposne OBJECT METHODS
A *Response* object's toString() method is set up to return the string
value of the language identifier.
var languid = new Languid();
var ident = languid.identify("some english text");
# prints "language is english" if successful
# prints "language is " if not
alert("language is " + ident);
obj.success()
Returns true or false.
obj.code()
Returns an ISO code identifying the language result.
obj.err()
Returns the error code associated with a failed request.
obj.errstr()
Returns an optional error string associated with a failed request.
VERSION
1.0
DATE
$Date: 2004/11/17 16:52:05 $
AUTHOR
Aaron Straup Cope
SEE ALSO
http://languid.cantbedone.org
LICENSE
Copyright (c) 2004 Aaron Straup Cope. All Rights Reserved.
This is free software, you may use it and distribute it under the same
terms as the Perl Artistic License.