|
| 1 | +# String Checker JS |
| 2 | + |
| 3 | +Scan TypeScript and JavaScript documents for non-technical strings. |
| 4 | + |
| 5 | +The aim is to help identifying strings in code that might need to be translated. |
| 6 | +Such strings should be moved in a dedicated resource file for translation purpose. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +**Scan** workspace documents, and **navigate** from string to string in source code: |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +**Switch** view to browse detected strings: |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +Add **custom rules** to improve string detection: |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +**Search** for strings in view: |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +### Detection providers |
| 27 | + |
| 28 | +Strings are evaluated by different providers, each being dedicated to a specific area. |
| 29 | + |
| 30 | +| Provider | Description | Example | |
| 31 | +|---|---|---| |
| 32 | +| Keywords provider | Detects strings from **user list**. | "far fa-smile" will be detected as a [Font Awesome smile icon](https://fontawesome.com/icons/smile?style=regular). | |
| 33 | +| Class provider | Detects strings as **class names**. | | |
| 34 | +| Code provider | Detects strings as **code** (variable names). | "../path/to/my/file" will be detected as a path.<br>"someVariable" will be detected as a camel case variable. | |
| 35 | +| Natural language provider | Detects strings as **natural language**. | ["Ceci n'est pas une pipe"](https://en.wikipedia.org/wiki/Ren%C3%A9_Magritte) will be detected as french language. | |
| 36 | +| Entropy provider | Detects string as **[Gibberish](https://en.wikipedia.org/wiki/Gibberish)**.<br>String [entropy](https://en.wikipedia.org/wiki/Entropy_(information_theory)) threshold can be configured in settings (`entropy.threshold`, default = 3). | "abbcccddddeeeee" has an entropy of 2.15.<br>"dd/MM/yyyy hh:mm:ss" has an entropy of 2.88.<br>["Gloubi-boulga"](https://fr.wikipedia.org/wiki/Gloubi-boulga) has an entropy of 2.93. | |
| 37 | +| String provider | **Pass-through** detection. | *Any string will be detected as such.* | |
| 38 | + |
| 39 | +The `string.checker.js.testString` [command](#extension-settings) brings a convenient way to test all providers for a given string. |
| 40 | + |
| 41 | +<!-- TODO: Image URLs in README.md and CHANGELOG.md need to resolve to https URLs. --> |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +## Requirements |
| 46 | + |
| 47 | +*There are no known requirements.* |
| 48 | + |
| 49 | +## Extension Settings |
| 50 | + |
| 51 | +This extension contributes the following settings: |
| 52 | + |
| 53 | +- `string.checker.js.scanDocument`: scan selected document. |
| 54 | +- `string.checker.js.scanDocumentIncludeAll`: scan selected document for any string. |
| 55 | +- `string.checker.js.scanDocumentWorkspace`: scan workspace documents. |
| 56 | +- `string.checker.js.scanDocumentWorkspaceIncludeAll`: scan workspace documents for any string. |
| 57 | +- `string.checker.js.switchView`: switch between file/token and token/file view. |
| 58 | +- `string.checker.js.excludeParentFolderPath`: exclude a file (using its path) containing folder from scan [1]. |
| 59 | +- `string.checker.js.excludeParentFolderName`: exclude a file (using its name) containing folder from scan [1]. |
| 60 | +- `string.checker.js.excludeFilePath`: exclude a file (using its path) from scan [1]. |
| 61 | +- `string.checker.js.excludeFileName`: exclude a file (using its name) from scan [1]. |
| 62 | +- `string.checker.js.excludeToken`: exclude a token from scan result. |
| 63 | +- `string.checker.js.includeToken`: include a token to scan result. |
| 64 | +- `string.checker.js.selectTreeItem`: select token in document. |
| 65 | +- `string.checker.js.filterTokens`: filter tokens view. |
| 66 | +- `string.checker.js.testString`: test a string with all detection [providers](#detection-providers). |
| 67 | +- `string.checker.js.showVersion`: display String Checker JS version. |
| 68 | + |
| 69 | +- [1] **Path exclusion** is based on the full path (`/path/to/my/file.js`), while **name exclusion** only uses the last part (`file.js`for a file, `my`for a folder), which means if the same name is found in another folder, it will be excluded too. |
| 70 | + |
| 71 | +## Known Issues |
| 72 | + |
| 73 | +Here are a few common issues. |
| 74 | + |
| 75 | +- String detection by language provider is based on statistical analysis. The longer the string, the more accurate the detection. |
| 76 | + |
| 77 | +## Release Notes |
| 78 | + |
| 79 | +### 0.0.1 |
| 80 | + |
| 81 | +Initial release. |
| 82 | + |
| 83 | +## Mentions |
| 84 | + |
| 85 | +- [Font Awesome](https://fontawesome.com/icons/) icon is used for tokens activity bar. |
| 86 | +- [freeicons.io](https://www.freeicons.io/) icons are used for tokens view. |
| 87 | +- [franc](https://github.com/wooorm/franc) library is used for natural language detection. |
| 88 | +- [TypeScript-Node-Starter](https://github.com/Microsoft/TypeScript-Node-Starter) Microsoft sample project is used for demonstration purpose. |
0 commit comments