Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a demo of the ability to filter errors from xliffs #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
A sample to demonstrate how to call and use the ilib-lint tool to find
i18n problems in your code.

The lint tool can check for problems in xliff files, or in source files
The lint tool can check for problems in xliff files, or in source files
of various types, based on plugins.

# Usage

## Reporting on Problems

To run the sample, first run `npm install` to install the lint tool
and the python plugins for it.

Expand Down Expand Up @@ -37,9 +39,58 @@ to load the plugins it needs and to understand what to check and which
rules to apply. Take a look at it to better understand a working
example of this file.

## Filtering Out Some of the Problems

Some of the problems can be automatically filtered out using the
new ErrorFilterTransformer plugin for the lint tool. To run it, call:

```
$ npm run lint:fix
```

This will run the linter, collect the results, print them to the
console, then delete the parts of the xliff files that have problems.
After this run, you will be able to do `git diff` and see the
translation units that had error level problems in the output
were deleted.

The filtering is accomplished by two things:

- In the file type definition, add in the error filter transformer
and the xliff serializer. These tell the linter how to run the error
filter and how to write out any modified files. If files are not
modified, no output is generated.
- On the command-line, give the `--overwrite` flag, which tells
the linter to overwrite the files with the filtered versions of them,
correcting them in-place. If you use the `--write` flag instead,
it will create a new, parallel file with a `.modified` extension
that is the filtered version of the file and it will leave the
originals alone.

Here is what the new file type definition for xliff files looks
like:

```json
{
"filetypes": {
"xliff": {
"parsers": ["xliff"],
"ruleset": [
"generic",
"python",
"python-gnu",
"overrides"
],
"transformers": [ "errorfilter" ],
"serializer": "xliff"
}
}
}
```

## License

Copyright © 2023-2024, JEDLSoft
Copyright © 2023-2025, JEDLSoft

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -56,6 +107,15 @@ limitations under the License.

## Release Notes

### v2.2.0

- added support for demonstrating filtering based on error results

### v2.1.0

- added samples to demonstrate the new snake case, camel case,
and kabob case rules

### v2.0.0

- added support for ilib-lint v2.0.0
Expand Down
5 changes: 4 additions & 1 deletion lint/ilib-lint-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
]
},
"xliff": {
"parsers": ["xliff"],
"ruleset": [
"generic",
"python",
"python-gnu",
"overrides"
]
],
"transformers": [ "errorfilter" ],
"serializer": "xliff"
}
},
"paths": {
Expand Down
12 changes: 7 additions & 5 deletions lint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ilib-sample",
"version": "2.1.0",
"version": "2.2.0",
"main": "./src/index.js",
"description": "Sample application that demostrates how to use the ilib-lint tool with python strings",
"keywords": [
Expand Down Expand Up @@ -49,14 +49,16 @@
},
"scripts": {
"lint": "ilib-lint",
"lint:fix": "ilib-lint --overwrite",
"debug": "node --inspect-brk node_modules/ilib-lint/src/index.js",
"clean": "git clean -f -d *",
"test": "echo success"
},
"dependencies": {
"ilib-lint": "^2.6.0",
"ilib-lint-python": "^2.0.0",
"ilib-lint-python-gnu": "^2.0.0",
"ilib-lint-react": "^2.0.0"
"ilib-lint": "^2.7.2",
"ilib-lint-common": "^3.1.2",
"ilib-lint-python": "^2.0.3",
"ilib-lint-python-gnu": "^2.0.3",
"ilib-lint-react": "^2.0.3"
}
}
Loading