Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s-kainet/spfx-check-locale
Check the consistency of your localization files inside SharePoint Framework projects.
https://github.com/s-kainet/spfx-check-locale
sharepoint-framework spfx vscode vscode-extension
Last synced: about 1 month ago
JSON representation
Check the consistency of your localization files inside SharePoint Framework projects.
- Host: GitHub
- URL: https://github.com/s-kainet/spfx-check-locale
- Owner: s-KaiNet
- License: mit
- Created: 2021-04-03T22:38:10.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-15T22:12:34.000Z (over 2 years ago)
- Last Synced: 2024-09-24T10:04:52.987Z (about 2 months ago)
- Topics: sharepoint-framework, spfx, vscode, vscode-extension
- Language: TypeScript
- Homepage: https://marketplace.visualstudio.com/items?itemName=s-kainet.spfx-check-locale
- Size: 4.33 MB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Checks that your localization files match the schema inside `mystrings.d.ts`
[![npm version](https://badge.fury.io/js/spfx-check-locale.svg)](https://badge.fury.io/js/spfx-check-locale)
`spfx-check-locale` is a Node.js module which allows you to check the consistency of your localization files inside SharePoint Framework projects, i.e. localization files match the schema inside `mystrings.d.ts`.
Also available as a [VSCode extension](https://github.com/s-KaiNet/spfx-check-locale/blob/master/vscode/README.md) to support nice real-time error reporting.
## How to use
### Install
`npm install spfx-check-locale --save-dev`
### Update `gulpfile.js`
```javascript
const checkLocales = require('spfx-check-locale').checkForErrors;const argv = build.rig.getYargs().argv;
if (argv.production) {
const check = build.subTask('check-locales', function (gulp, buildOptions, done) {
checkLocales({
projectPath: buildOptions.rootPath,
printErrors: true
})
.then(result => {
if (result.diagnosticData.length === 0) {
done();
} else {
done('Found errors in localization files');
}
}).catch(done);
});build.rig.addPostBuildTask(build.task('check-locales', check));
}
```Now every time you build your SPFx solution for the production `spfx-check-locale` will check the consistency of all localization files, will print errors report and will fail a build if there are any errors.
> Why on production build only? Because the checking takes from 1 to 3 seconds, thus no reason to make your `serve` process slower. Also, with [VSCode extension](https://github.com/s-KaiNet/spfx-check-locale/blob/master/vscode/README.md) you have nice real-time error highlights without hurting performance.
## API
### checkForErrors(options)
Asynchronously checks your SPFx project for inconsistencies in localization files
#### params
- `options` - required, options object with below properties:
- `projectPath` - required string, an absolute path to your SPFx solution
- `printErrors` - optional boolean, whether to print errors in console#### returns
A promise, which resolves to a `CheckResults` object