Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
grunt-google-translate
Advanced tools
Readme
A build task to translate JSON files to other languages using Google's Translation API. Pairs very well with angular-translate.
Massive thanks to MartyIce for allowing me to use the grunt-google-translate namespace.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-google-translate --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-google-translate');
In your project's Gruntfile, add a section named google_translate
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
google_translate: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
Type: String
Default value: ', '
The API key used to access Google Translation services.
In this example, I passed in a JSON file with english text. It will then create two files in the i18n/
folder called ru.json and zh-CN.json for Russian and Chinese respectively.
Note: This plugin will try and deduce the suffix (file type), so you don't need to explicity specify it. If you need it to have a different suffix, then specify the suffix
as shown in the next example.
grunt.initConfig({
google_translate: {
default_options: {
options: {
googleApiKey: YOUR_API_KEY_HERE
},
files: [{
src: '<%= yeoman.client %>/i18n/en.json',
sourceLanguage: 'en',
targetLanguages: ['ru', 'zh-CN'],
dest: '<%= yeoman.client %>/i18n/'
}]
}
}
});
In this example, two files are being translated, one called locale-en.json
and another called locale-fr.json
. They are in different folders, and will create translated files in the same i18n/
folder.
Notice how the prefix and suffix is specified, it means the translated files will be named like locale-de.json
instead of de.json
.
grunt.initConfig({
google_translate: {
default_options: {
options: {
googleApiKey: YOUR_API_KEY_HERE
},
files: [{
src: '<%= yeoman.client %>/i18n/locale-en.json',
sourceLanguage: 'en',
targetLanguages: ['ru', 'zh-CN'],
dest: '<%= yeoman.client %>/i18n/',
prefix: 'locale-',
suffix: '.json'
}, {
src: '<%= yeoman.client %>/specialFolder/locale-fr.json',
sourceLanguage: 'fr',
targetLanguages: ['de', 'zh-CN'],
dest: '<%= yeoman.client %>/i18n/',
prefix: 'locale-',
suffix: '.json'
},]
}
}
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
(Nothing yet)
FAQs
A build task to translate JSON files to other languages using Google's Translation API. Pairs very well with angular-translate.
The npm package grunt-google-translate receives a total of 184 weekly downloads. As such, grunt-google-translate popularity was classified as not popular.
We found that grunt-google-translate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.