nocjk
is a simple CLI tool and library to detect CJK (Chinese, Japanese, and Korean) text.
go install github.com/aethiopicuschan/nocjk/cmd/nocjk@latest
nocjk .
When CJK text is detected, the CLI exits with error code 1.
If you want to ignore the detection of a specific language, you can use the following option.
--ignore-chinese
to ignore Chinese text--ignore-japanese
to ignore Japanese text--ignore-korean
to ignore Korean text
You can also define ignore rules using a .nocjkignore
file in your project root. The format of .nocjkignore
is fully compatible with .gitignore
. Files and directories matching the patterns in this file will be skipped during CJK text detection. This is especially useful when you want to exclude certain generated files or third-party code from being analyzed.
go get -u github.com/aethiopicuschan/nocjk/pkg/nocjk
nocjk
provides FindChineseLines
, FindJapaneseLines
, FindKoreanLines
and FindCJKLines
functions to detect CJK text in a string. More information can be found in the documentation.
You can easily integrate nocjk
into your GitHub Actions workflows to automatically detect CJK text during code changes. Here is a basic example:
jobs:
check-cjk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Detect CJK text
uses: aethiopicuschan/nocjk/actions/nocjk-action@v1.2.0
with:
ignore_chinese: false
ignore_japanese: false
ignore_korean: false
args: "."
See nocjk-action on GitHub for more details.