https://github.com/cortesi/languages
GitHub's language data, compiled into a tiny, fast Rust library.
https://github.com/cortesi/languages
languages linguist
Last synced: about 1 month ago
JSON representation
GitHub's language data, compiled into a tiny, fast Rust library.
- Host: GitHub
- URL: https://github.com/cortesi/languages
- Owner: cortesi
- License: mit
- Created: 2025-07-25T05:15:52.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-07T00:33:34.000Z (2 months ago)
- Last Synced: 2025-08-07T02:32:25.388Z (2 months ago)
- Topics: languages, linguist
- Language: Rust
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://crates.io/crates/languages)
[](https://docs.rs/languages)# languages
> GitHub's language data, compiled into a tiny, fast Rust library. 🦀
This crate provides an efficient way to look up language information from
GitHub's Linguist `languages.yml` file. The data is parsed at compile-time and
baked directly into your binary, making lookups instantaneous with zero runtime
overhead.-----
## Features
- **Fast**: All data is stored in static `HashMap`s for instant, case-insensitive lookups.
- **Simple API**: Get language info by name, alias, extension, or CodeMirror mode.
- **Self-Contained**: No need to read files or parse YAML at runtime.-----
## Quickstart
1. Add `languages` to your `Cargo.toml`:
```toml
[dependencies]
languages = "0.1.0" # Replace with the latest version
```2. Use the lookup functions:
```rust
let lang = languages::from_extension("rs").unwrap();
assert_eq!(lang.name, "Rust");
assert_eq!(lang.language_type, "programming");
assert_eq!(lang.color, Some("#dea584"));// Look up by name (case-insensitive)
let python = languages::from_name("Python").unwrap();
assert!(python.extensions.unwrap().contains(&".py"));// Look up by alias
let cpp = languages::from_name("cpp").unwrap();
assert_eq!(cpp.name, "C++");
```-----
## How It Works
This crate uses a `build.rs` script that parses `languages.yml` and generates
the necessary Rust code. To update the language data to the latest version from
GitHub, simply run the `download_languages.sh` script and recompile your
project.# Related Projects
This library was written to be used in the
[snips](https://github.com/cortesi/snips) tool, which is also used to maintain
the code examples in this README.# License and Acknowledgements
The code for the languages crate is licensed under the MIT License.
The language data is sourced from the [GitHub
Linguist](https://github.com/github-linguist/linguist) project, which is
distributed under the MIT license and is copyright of GitHub, Inc.