Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
translate text from one language to another on node.js and the browser. 30+ languages supported, simple as cake.
var sys = require('sys');
var colors = require('colors'); // colors are fun!
var translate = require('./lib/translate');
// note: the translator is English=>Spanish by default
translate.text('I want tacos please.', function(err, text){
sys.puts('I want tacos please.'.red + ' => '.cyan + text.yellow);
var input = 'Spanish', output = "Japanese";
translate.text({input:input,output:output}, text, function(err, text2){
var input = 'Japanese', output = "English";
sys.puts(text.yellow + ' => '.cyan + text2.blue);
translate.text({input:input,output:output}, text, function(err, text3){
sys.puts(text2.blue + ' => '.cyan + text3.red);
sys.puts('English'.red+'=>'+'Spanish'.yellow+'=>'+'Japanese'.blue+'=>'+'English'.red +'\ntaco request has been normalized. ^_^'.green);
});
});
});
<!-- main translate.js library -->
<script type="text/javascript" src="./lib/translate.js"></script>
<!-- load up the languages definition file -->
<script type="text/javascript" src="./lib/languages.js"></script>
<!-- jquery not required, just used in the demo page -->
<script type="text/javascript" src="./vendor/jquery.js"></script>
<script type="text/javascript">
var languages;
$(document).ready(function(){
languages = getLangs();
// populate the select box
for(var lang in languages){
$('#langInput').append('<option value = "'+lang+'">' + lang + '</option>');
}
for(var lang in languages){
$('#langOutput').append('<option value = "'+lang+'">' + lang + '</option>');
}
/***** NAMED EVENTS *****/
$(document).bind('##TRANSLATE_TEXT##', function(e){
$('#run').attr('disabled','disabled');
$('#run').val('translating...');
var input = $('#langInput').val(), output = $('#langOutput').val();
translate.text({input:input,output:output}, $('#theCode').val(), function(result){
$('#run').attr('disabled','');
$('#run').val('<== translate ==>');
$('#output').val( result );
});
});
/**** END NAMED EVENTS ****/
/**** BIND UI EVENTS ****/
// select box change
$('#langSelector').change(function(){
$(document).trigger('##CHANGE_LANGUAGE##', {"fontName":$(this).val()})
});
$('#run').click(function(e){
$(document).trigger('##TRANSLATE_TEXT##');
});
/**** END UI BIND EVENTS ****/
// little bit of a onReady hack. i'll fix the API a bit so this can be done better
$(document).trigger('##CHANGE_LANGUAGE##', {"fontName":'Doh'});
$('#langInput').val('English');
$('#langOutput').val('Spanish');
});
</script>
Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese | Croatian Czech Danish Dutch English Estonian Filipino Finnish French Galician | Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish | Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian Persian | Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish | Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish |
translate.js uses the google api and requires an internet connection
if you want to actually hear the translated text as audio you could use say.js
FAQs
Translate text to different languages on node.js and the browser
The npm package translate receives a total of 5,616 weekly downloads. As such, translate popularity was classified as popular.
We found that translate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.