
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@linagora/i18n-checker
Advanced tools
Validate translation files
checker(options, (err, report) => {
if (err) {
console.log(err);
} else {
console.log('Report:', report);
}
});
Where options
is an object with:
baseDir
: the absolute path to the base directory that contains directories to scandirs
: list of directories, in which:
localeDir
: relative path to the directory containing locale files (.json
files)core
: true
if current directory contains core locale files. One of the
directories in the list must be marked as core.verifyOptions
: options to verify locale files
defaultLocale
: the default locale (default: 'en'
)locales
: list of locales (e.g. ['en', 'fr', 'vi']
)rules
: list of rules to check (omit to check all rules)const checker = require('@linagora/i18n-checker');
const reporter = checker.reporters.standard;
const options = {
baseDir: __dirname,
dirs: [{
localeDir: 'backend/i18n/locales',
core: true
}, {
localeDir: 'modules/contact/i18n/locales'
}, {
localeDir: 'modules/calendar/i18n/locales'
}],
verifyOptions: {
defaultLocale: 'en',
locales: ['en', 'fr', 'vi'],
rules: [
'all-locales-present',
'valid-json-file',
'default-locale-translate',
'no-duplicate-with-core',
'all-keys-translated'
]
}
};
checker(options, (err, report) {
reporter(report);
});
All keys translated in default locale must be translated in other locales.
All directories must contain translation files for all locales defined in
options.verifyOptions.locales
list.
In translation file of the default locale, value must have the same value as key.
No white space character at the beginning or the end of the key.
Keys are duplicated between modules should be in core.
Keys are translated in core module must not be translated again in modules.
All keys used in template files must be translated.
All locale keys defined in core module must be used in core's template files or modules's template files.
All locale keys defined in a module must be used in that module's template files.
Every translation files must be valid JSON file and has no duplicate keys.
grunt lint # lint JS files
grunt test # run test cases
grunt # grunt lint test
1/ Create a new file in src/rules
directory named rule-id.js
.
2/ Each rule is a function, it receives the options
and returns a promise
which resolves the report:
module.exports = function(options) {
const report = [{
filePath: 'module/contact/en.json',
messages: [{
severity: 2,
message: 'something wrong'
}, {
//....
}]
}, {
filePath: 'module/calendar/vi.json',
messages: [{
severity: 1,
message: 'something not OK'
}]
}];
return q(report);
}
3/ Update documentation and write test for the new rule.
FAQs
A JS library to validate translation files
We found that @linagora/i18n-checker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.