Skip to content

LanguageGuard

LanguageGuard restricts content to specified languages using Unicode script detection and character frequency analysis. No external model required.

Overview

Property Value
Latency <5ms
Memory 50 KB
Async No
ML Required No
License Community

Supported Scripts

Script Languages
Latin English, French, Spanish, German, Portuguese
Cyrillic Russian, Ukrainian, Bulgarian
CJK Chinese, Japanese (Kanji), Korean (Hanja)
Arabic Arabic, Farsi, Urdu
Devanagari Hindi, Sanskrit, Marathi
Hangul Korean
Hiragana/Katakana Japanese
Greek Greek
Thai Thai
Hebrew Hebrew

Usage

Rust

use oxideshield_guard::guards::LanguageGuard;
use oxideshield_guard::{Guard, GuardAction};

let guard = LanguageGuard::new("lang")
    .allow_script(Script::Latin)
    .with_action(GuardAction::Block);

let result = guard.check("Hello world");
assert!(result.passed);

Python

from oxideshield import language_guard

guard = language_guard(allowed_scripts=["latin"], action="block")
result = guard.check("Hello world")
assert result.passed

Configuration

guards:
  - type: language
    action: block
    allowed_scripts:
      - latin
      - cyrillic

Research References