A simple command-line tool to detect the language of a given text using:
franc
for language detectionlangs
for mapping ISO 639-3 codes to readable namescolors
for colorized console output
- Detects the language of input text based on statistical analysis.
- Provides the language name and ISO 639-3 code.
- Handles cases where the language cannot be determined or is unsupported.
- Encourages longer input for better accuracy.
- Outputs colorized, readable messages in the terminal.
- Clone the repository:
git clone https://github.com/Misba0019/LangDetect.git cd LangDetect
- Install dependencies:
npm install
- Run the tool:
node index.js "Your text here"
- Example:
node index.js "Hello, this tool can guess different languages."
- Output:
Detected language code: eng The language appears to be: English
Hereโs what a sample run looks like:
- Node.js (version 18 or higher)
- The tool takes a text input from the command line.
- It uses the
franc
library to detect the language code. - The
langs
library maps the detected code to a language name. - If the language cannot be determined (
und
) or is unsupported, the tool provides feedback to the user.
- Short or ambiguous text may return
und
(undefined) - Some rare languages may not be supported by the
langs
package.
Powered by the open-source libraries:
This project is licensed under the MIT License. See the LICENSE file for details.