
Product
Introducing .NET Support in Socket
Socket now supports .NET, bringing supply chain security and SBOM accuracy to NuGet and MSBuild-powered C# projects.
grunt-sh-i18n-props
Advanced tools
Grunt plugin for compiling multiple *.properties files into a single JSON file.
Grunt plugin for compiling multiple *.properties files into a single JSON file.
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-sh-i18n-props --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-sh-i18n-props');
In your project's Gruntfile, add a section named sh_i18n_props
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
sh_i18n_props: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
Type: Object
This config option is required
An object value, normally it should specify the i18n/locales folder in the app source folder and where all the source files should be copied into the deployment build environment, this value normally is a pattern value which can be passed into the grunt API grunt.file.expandMapping
, one example is like below:
localeFilesExpandPatterns: {
src: ['**/*.properties'],
cwd: 'app/multi-event/i18n',
dest: '<%= buildDevPath %><%= multiFeatureI18nPath %>',
rename: function(dest, matchedSrcPath, options) {
return path.join(dest, matchedSrcPath);
}
}
And here is a detail example about how to use the grunt.file.expandMapping
API.
Type: Array
This config option is required
It specify the implemented locales list for current application.
Type: Function
Returned value type: String
, this is required
It return the generated localized javascript properties file path in deployment folder structure.
Type: String
This config option is required
It specify the keyPrefix in all properties files under i18n folder to make sure all the properties key have to conform to the key constrains.
Type: String
This config option is required
It specify the module id of generated i18n properties file, See below exmaple:
If the options has the following config
options: {
...
i18nPropsId: 'geolocation-i18nProps'
...
}
Then the generated i18nPropsForScripts.js will be like below:
define('geolocation-i18nProps', [], function(){
return {
"common.components.geolocation.defaultLink.text": "all locations",
"common.components.geolocation.popular-in.text": "Popular events in ",
"common.components.geolocation.popular-near.text": "Popular events near "
};
});
Type: Array
No default value, this is optional
It specify the module dependencies of generated i18n properties file, normally app don't need to config it.
Type: Array
Default value: ['common/**/*.properties']
, this is optional
It specify where the common properties file locate, it should be relative to the locale's folder. Normally, this value should not be changed and app can just accept the default value.
Type: Array
Default value: ['scripts/**/*.properties']
, this is optional
It specify where the scripts properties file locate, it should be relative to the locale's folder. Normally, this value should not be changed and app can just accept the default value.
Type: Array
Default value: 'i18nPropsForScripts'
, this is optional
It specify the generated javascript properties file name.
The exmaple below is coming from https://github.corp.ebay.com/rchavan/app-sellflow/tree/selli18n
.
meventdev: {
options: {
localeFilesExpandPatterns: {
src: ['**/*.properties'],
cwd: 'app/multi-event/i18n',
dest: '<%= buildDevPath %><%= multiFeatureI18nPath %>',
rename: function(dest, matchedSrcPath, options) {
return path.join(dest, matchedSrcPath);
}
},
implementedLocalesList: ['en-us', 'en-gb'],
scriptsPropsFileName: '<%= scriptsPropsFileName %>',
getScriptsPropsFilePath: function (settings) {
var task = settings.task,
locale = settings.locale,
scriptsPropsFileName = settings.scriptsPropsFileName,
buildDevPath = grunt.config.get('buildDevPath'),
multiFeatureScriptsPath = grunt.config.get('multiFeatureScriptsPath'),
destpath = '';
destpath = path.join(buildDevPath, multiFeatureScriptsPath, locale, scriptsPropsFileName + '.js');
grunt.verbose.subhead('[i18n-props] ==== scriptsPropsFilePath-----', destpath);
return destpath;
},
keyPrefix: '<%= config.appName %>' + 'multiEvent'
},
}
And here is another exmaple which is coming from https://github.corp.ebay.com/Stubhub/app-reference/tree/develop
.
dev:{
options:{
localeFilesExpandPatterns: {
src: ['**/*.properties'],
dest: '<%= buildDevPath %><%= i18nRootPath %>',
cwd: 'app/i18n',
rename: function(dest, matchedSrcPath, options) {
return path.join(dest, matchedSrcPath);
}
},
implementedLocalesList: ['en-us', 'en-gb', 'de-de'],
getScriptsPropsFilePath: function (settings) {
var locale = settings.locale,
scriptsPropsFileName = settings.scriptsPropsFileName,
buildDevPath = grunt.config.get('buildDevPath'),
featureScriptsPath = grunt.config.get('featureScriptsPath'),
destpath = '';
destpath = path.join(buildDevPath, featureScriptsPath, locale, scriptsPropsFileName + '.js');
return destpath;
},
keyPrefix: '<%= config.appName %>',
scriptsPropsFileName: '<%= scriptsPropsFileName %>'
},
}
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
Grunt plugin for compiling multiple *.properties files into a single JSON file.
The npm package grunt-sh-i18n-props receives a total of 2 weekly downloads. As such, grunt-sh-i18n-props popularity was classified as not popular.
We found that grunt-sh-i18n-props 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.
Product
Socket now supports .NET, bringing supply chain security and SBOM accuracy to NuGet and MSBuild-powered C# projects.
Research
Malicious npm packages posing as Telegram bot libraries install SSH backdoors and exfiltrate data from Linux developer machines.
Security News
pip, PDM, pip-audit, and the packaging library are already adding support for Python’s new lock file format.