langid
is a command-line tool for detecting the language of input text using Apple's Natural Language Processing framework.
- macOS v14 or later
- Swift 5.10 or later
To build the project, run:
make build
This command compiles the project in release mode.
To install the langid
command to /usr/local/bin
, run:
sudo make install
This command builds the project and copies the executable to /usr/local/bin
.
To remove the installed langid
command, run:
sudo make uninstall
To clean the build artifacts, run:
make clean
To update the project dependencies, run:
make update-deps
To format all Swift files in the project using swift-format, run:
make format
This command will format all Swift files in the Sources
directory and the Package.swift
file.
After installation, you can use langid
in two ways:
-
Provide text as a command-line argument:
langid "Your text here"
-
Pipe text to
langid
:echo "Your text here" | langid
The command will output the detected language code (e.g., "en" for English, "ja" for Japanese).
$ langid "Hello, world!"
en
$ echo "Bonjour le monde" | langid
fr
MIT License