Skip to content

Commit

Permalink
Merge pull request #4 from Lawndlwd/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Lawndlwd authored May 25, 2024
2 parents 271ab10 + 4bb426f commit e7fe52f
Show file tree
Hide file tree
Showing 9 changed files with 2,303 additions and 1,575 deletions.
63 changes: 38 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Translation Cleaner
# Unused i18n

`translation-cleaner` is a tool designed to help developers manage and clean up unused translation keys in their localization files. This utility ensures that your translation files remain clean and free from unused keys, making your localization process more efficient.
`unused-i18n` is a tool designed to help developers manage and clean up unused translation keys in their localization files. This utility ensures that your translation files remain clean and free from unused keys, making your localization process more efficient.

## Features

Expand All @@ -11,46 +11,59 @@

## Installation

You can install `translation-cleaner` via npm:
You can install `unused-i18n` via npm:

```sh
npm install -g translation-cleaner
```
npm install -g unused-i18n

Or pnpm
or

```sh
pnpm install -g translation-cleaner
npm install -D unused-i18n
```

## Configuration

Create a translation-cleaner.config.json, translation-cleaner.config.js, or translation-cleaner.config.ts file in the root of your project. Here's an example configuration:
Create a unused-i18n.config.json or unused-i18n.config.js file in the root of your project. Here's an example configuration:

```json
{
"paths": [
```ts
import type { Config } from 'unused-i18n'

const config = {
paths: [
{
"srcPath": ["src/pages/products"],
"localPath": "src/pages/products/locales"
}
srcPath: ['src/pages/products'],
localPath: 'src/pages/products/locales',
},
],
"localesExtensions": "js",
"localesNames": "en",
"scopedNames": ["scopedT", "scopedTOne"],
"ignorePaths": ["src/pages/products/ignoreThisFolder"],
"excludeKey": ["someKey"]
}
localesExtensions: 'ts',
localesNames: 'en',
scopedNames: ['scopedT', 'scopedTOne'],
ignorePaths: ['src/pages/products/ignoreThisFolder'],
excludeKey: ['someKey'],
} satisfies Config

export default config
```

| Option | Type | Default | Required | Description |
| ------------------- | ---------------- | ------- | -------- | ---------------------------------------------------------------------------- |
| `paths` | Array of Objects | `[]` | Yes | An array of objects defining the source paths and local paths to be checked. |
| `paths.srcPath` | Array of Strings | `[]` | Yes | Source paths to search for translations. |
| `paths.localPath` | Strings | `""` | Yes | Path to the translation files. |
| `localesExtensions` | String | `js` | No | Extension of the locale files. |
| `localesNames` | String | `en` | No | Name of the locale files without the extension. |
| `scopedNames` | Array of Strings | `[]` | No | Names of the scoped translation functions used in your project. |
| `ignorePaths` | Array of Strings | `[]` | No | Paths to be ignored during the search. |
| `excludeKey` | Array of Strings | `[]` | No | Specific translation keys to be excluded from the removal process. |

## Usage

### Using with Config File

To use translation-cleaner with your config file, simply run:
To use unused-i18n with your config file, simply run:

```sh
npx translation-cleaner
npx unused-i18n display
```

### Using with Command Line Options
Expand All @@ -60,13 +73,13 @@ You can also specify the source and local paths directly in the command line:
##### Display Unused Translations

```sh
npx translation-cleaner display --srcPath="src/folders/bla" --localPath="src/folders/bla/locales"
npx unused-i18n display --srcPath="src/folders/bla" --localPath="src/folders/bla/locales"
```

##### Remove Unused Translations

```sh
npx translation-cleaner remove --srcPath="src/folders/bla" --localPath="src/folders/bla/locales"
npx unused-i18n remove --srcPath="src/folders/bla" --localPath="src/folders/bla/locales"
```

## API
Expand Down
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "translation-cleaner",
"version": "0.1.4",
"name": "unused-i18n",
"version": "0.1.6",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"repository": {
"type": "git",
"url": "https://github.com/Lawndlwd/unused-i18n.git"
},
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"bin": {
"translation-cleaner": "dist/cli.cjs"
"unused-i18n": "dist/index.cjs"
},
"scripts": {
"build": "rollup -c",
Expand All @@ -17,13 +20,7 @@
},
"dependencies": {
"ansi-colors": "^4.1.3",
"boxen": "^7.1.1",
"cli-boxes": "^4.0.0",
"commander": "^12.1.0",
"string-width": "^7.1.0",
"ts-node": "^9.1.1",
"tslib": "^2.6.2",
"use-i18n": "^1.0.1"
"commander": "^12.1.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.8",
Expand All @@ -35,6 +32,8 @@
"@vitest/coverage-istanbul": "^1.6.0",
"rollup": "^4.18.0",
"rollup-plugin-dts": "^6.1.1",
"ts-node": "^9.1.1",
"rollup-plugin-filesize": "^10.0.0",
"typescript": "^4.9.5",
"vitest": "^1.6.0"
}
Expand Down
Loading

0 comments on commit e7fe52f

Please sign in to comment.