Metadata-Version: 2.5
Name: imlo-lint
Version: 0.1.0
Summary: Find and fix old-alphabet (1995) Uzbek Latin text and migrate it to the 2026 Latin alphabet.
Project-URL: Homepage, https://github.com/azamatofb/imlo-lint
Project-URL: Issues, https://github.com/azamatofb/imlo-lint/issues
Author: imlo-lint contributors
License-Expression: MIT
License-File: LICENSE
Keywords: alphabet,i18n,l10n,lint,locale,transliteration,uzbek
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Internationalization
Classifier: Topic :: Software Development :: Localization
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: alifbo<0.7,>=0.6
Requires-Dist: tomli>=1.1; python_version < '3.11'
Provides-Extra: audit
Provides-Extra: dev
Requires-Dist: jsonschema>=4; extra == 'dev'
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest-cov>=4; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Description-Content-Type: text/markdown

# imlo-lint

> Find and fix old-alphabet Uzbek text in your codebase, locale files and website — before the 2026 Latin alphabet takes effect on **22 April 2027**.

**Status:** pre-alpha. Works from source: plain text, Markdown, JSON i18n, gettext, Android, Apple (`.strings`, `.stringsdict`, `.xcstrings`), Flutter ARB, XLIFF, YAML, HTML and Java `.properties`; opt-in Uzbek Cyrillic migration; `scan` / `check` / `fix` / `text`; text, JSON, SARIF and GitHub reports; GitHub Action and pre-commit hooks; `imlo audit` website reports. Nothing is published on PyPI yet.

Uzbekistan's updated Latin alphabet replaces `sh → ş`, `ch → ç`, `oʻ → ö`, `gʻ → ğ`. Converting a sentence is a solved problem — several good engines exist (see [docs/LANDSCAPE.md](docs/LANDSCAPE.md)). Migrating a **real project** is not:

- translation files mix keys, placeholders (`{name}`, `%1$s`, `{{count}}`), ICU plurals, HTML and escaped quotes (`o\'zbek` in Android `strings.xml`);
- only `uz-Latn` values should change — never keys, never `ru`/`en`/`uz-Cyrl`;
- teams need a CI gate that fails when someone adds old-alphabet text after the migration.

`imlo-lint` is that tool. It does **not** reimplement transliteration: it uses the MIT-licensed [`alifbo`](https://github.com/azakapro/alifbo) engine and adds format-aware scanning, safe rewriting and CI integration.

## Usage

Not on PyPI yet — install from a clone (Python ≥ 3.10):

```bash
git clone https://github.com/azamatofb/imlo-lint && cd imlo-lint
pip install .
```

```bash
imlo scan .                      # report old-alphabet text: path:line:col: RULE old → new
imlo scan . --format json        # machine-readable report ("schema": 1)
imlo scan . --format sarif       # SARIF 2.1.0 for GitHub code scanning
imlo check . --format github     # ::error file=...:: annotations in GitHub Actions logs
imlo scan . --severity error     # hide warnings and info
imlo check .                     # same as scan; exit 1 on any error-level finding (CI)
imlo fix .                       # dry run: print a unified diff, change nothing
imlo fix . --check               # dry run; exit 1 if anything would change
imlo fix . --write               # apply the changes
imlo fix . --write --rules IMLO001,IMLO002
imlo text "Toshkent shahri"      # → Toşkent şahri
echo "o'g'il" | imlo text -      # → öğil
imlo rules                       # rule ids and default severities
```

Example output:

```
locales/uz.json:2:20: IMLO002 Do'konga → Dökonga [error]
locale/uz/LC_MESSAGES/messages.po:10:22: IMLO001 chipta → çipta [error]
```

Exit codes: `0` no error-level findings (or `fix` succeeded), `1` error-level findings
(`scan`/`check`) or pending changes (`fix --check`), `2` usage, config or I/O error, or an
unparsable file with `--strict`.

What gets changed: only Uzbek-Latin user-visible text — values in `uz` / `uz-Latn` / `uz_UZ`
locale files (never keys, never `ru`, `en` or `uz-Cyrl`), `msgstr` in `.po` files with an
Uzbek path or `Language: uz` header, and prose in `.txt` / `.md` files. Placeholders
(`{name}`, `{{count}}`, `%1$s`, `%(n)s`), ICU syntax, `$t(...)`, HTML tags and entities, URLs,
emails and Markdown code are protected. Outside Uzbek locale paths, a `.txt`/`.md` line is
touched only if it looks Uzbek (English prose such as *"check the shell"* is left alone).

### Migrating from Uzbek Cyrillic (opt-in)

```bash
imlo scan --from cyrillic locales/          # also report uz-Cyrl text
imlo fix --from cyrillic locales/ --write   # Тошкент шаҳри → Toşkent şahri
```

Only Uzbek Cyrillic sources are touched: `uz-Cyrl` / `uz_Cyrl` / `uz@cyrillic` paths and
metadata (PO `Language:`, XLIFF, ARB, `.xcstrings`, YAML root keys, HTML `lang`). Russian
(`ru`) is never converted. Files keep their names, so rename `uz-Cyrl` files yourself if
they become Latin. Letters the engine has to guess (`ъ`, `ь`, `щ`, `ц` → `s` or `ts`) are
reported as `IMLO005` with an explanation: review those words. Config:
`source_alphabet = "cyrillic"`.

### Configuration

`[tool.imlo]` in `pyproject.toml`, or `imlo.toml` (top level or `[tool.imlo]`), found from the
current directory upwards or given with `--config FILE`:

```toml
[tool.imlo]
include = ["locales/**", "docs/**/*.md"]   # only scan these; included .txt/.md count as Uzbek
exclude = ["vendor/**", "**/*.min.json"]
protected_terms = ["Chevrolet", "MyChaykhana"]  # never converted
exceptions = { "Ishoq" = "Isʼhoq" }        # word → replacement (the value is converted again)
severity = { IMLO003 = "error" }
exclude_keys = ["brand.*"]                 # JSON key paths to skip
ng_as_digraph = true
```

Suppress a line in `.txt` / `.md` with `imlo: ignore` (same line) or `imlo: ignore-next-line`
(e.g. `<!-- imlo: ignore-next-line -->`); in `.po` files a `# imlo: ignore` comment skips the
whole entry.

### Python API

```python
from imlo_lint import Config, fix_text, scan_text, scan_path, fix_path

fix_text("Do'konga xush kelibsiz, {name}!")  # 'Dökonga xuş kelibsiz, {name}!'
scan_text("Toshkent shahri")  # [Finding(..., rule_id='IMLO001', ...), ...]
fix_text("Chevrolet shahri", Config(protected_terms=("Chevrolet",)))
scan_path("locales")  # findings for files on disk
fix_path("locales", write=True)  # paths that were rewritten
```

### Rules

| id | Detects | Default |
|---|---|---|
| `IMLO000` | File could not be parsed (left untouched) | error |
| `IMLO001` | Old digraph `sh`/`ch` → `ş`/`ç` | error |
| `IMLO002` | `oʻ`/`gʻ` in any apostrophe variant → `ö`/`ğ` | error |
| `IMLO003` | Wrong apostrophe code point for tutuq belgisi → `ʼ` (U+02BC) | warning |
| `IMLO004` | Confusable letters (`ș` U+0219 → `ş`), Unicode normalization; `õ`/`ô` for `ö` (reported only, no fix) | warning |
| `IMLO005` | Ambiguous case resolved by the engine (`Ishoq` → `Isʼhoq`) | info |
| `IMLO006` | Old and new alphabet mixed in one value | warning |
| `IMLO007` | Uzbek Cyrillic → 2026 Latin (only with `--from cyrillic`) | error |

### CI and pre-commit

GitHub Action (annotations on the PR; `sarif: "true"` also uploads to code scanning):

```yaml
- uses: azamatofb/imlo-lint@main   # pin a commit SHA until the first release
  with:
    path: .
```

pre-commit:

```yaml
- repo: https://github.com/azamatofb/imlo-lint
  rev: <commit SHA>   # or v0.1.0 once released
  hooks:
    - id: imlo-check   # or imlo-fix to rewrite files
```

More, including GitLab CI: [docs/INTEGRATIONS.md](docs/INTEGRATIONS.md).

### Website audit

Read-only report of how much of a public site is still in the old alphabet:

```bash
imlo audit https://example.uz --max-pages 50 --delay 1 --format html > report.html
```

It sends only `GET` requests with the User-Agent `imlo-lint/<version> (+repo URL)`, honours
`robots.txt` (`Disallow`, `Crawl-delay`), waits between requests, stays on the same origin
(also on redirects), skips login/account/admin/cart links and files, never submits forms,
stops on `429`/`503`, and keeps no page content beyond counts and a few word examples.
Output: `text` (default), `json` or `html`. Only audit sites you are allowed to crawl.

## Supported formats

| Format | Files | Status |
|---|---|---|
| Plain text, Markdown | `*.txt`, `*.md` | ✅ v0.1 |
| gettext | `*.po`, `*.pot` | ✅ v0.1 |
| JSON i18n (i18next, vue-i18n, next-intl) | `uz.json`, `uz-Latn.json`, `locales/uz/*.json` | ✅ v0.1 |
| YAML (Rails, Symfony) | `uz.yml`, `messages.uz.yaml`, `uz:` root key | ✅ v0.2 (unreleased) |
| Android | `values-uz/strings.xml`, `values-b+uz+Latn/` | ✅ v0.2 (unreleased) |
| iOS / macOS | `uz.lproj/*.strings`, `*.stringsdict`, `*.xcstrings` | ✅ v0.2 (unreleased) |
| Flutter | `app_uz.arb` | ✅ v0.2 (unreleased) |
| XLIFF | `*.xlf`, `*.xliff` | ✅ v0.2 (unreleased) |
| HTML text nodes and `title`/`alt`/`placeholder`/`aria-label` | `*.html`, `*.htm`, templates | ✅ v0.2 (unreleased) |
| Java `.properties` | `*_uz.properties` | ✅ unreleased |

## Documentation

Website: <https://azamatofb.github.io/imlo-lint/> (built from `docs/` by
`.github/workflows/pages.yml` once GitHub Pages is enabled with the source *GitHub Actions*).

- [docs/QUICKSTART.md](docs/QUICKSTART.md) — quick start ([Özbekça](docs/QUICKSTART.uz.md), [Русский](docs/QUICKSTART.ru.md))
- [docs/SPEC.md](docs/SPEC.md) — behaviour, CLI, config, exit codes
- [docs/INTEGRATIONS.md](docs/INTEGRATIONS.md) — GitHub Action, pre-commit, GitLab CI
- [docs/RESEARCH.md](docs/RESEARCH.md) — the 2026 alphabet law and orthography sources
- [docs/LANDSCAPE.md](docs/LANDSCAPE.md) — existing tools and why this one exists
- [docs/TEST_CASES.md](docs/TEST_CASES.md) — golden cases
- [docs/ROADMAP.md](docs/ROADMAP.md)
- [docs/TASKS.md](docs/TASKS.md) — implementation tasks
- [CONTRIBUTING.md](CONTRIBUTING.md)
- [RELEASING.md](RELEASING.md) — how releases reach PyPI (Trusted Publishing)

<!-- imlo: ignore-next-line (written in the 1995 alphabet, official until 2027-04-22) -->
## Oʻzbekcha / По-русски

<!-- imlo: ignore-next-line (written in the 1995 alphabet, official until 2027-04-22) -->
**UZ:** `imlo-lint` — loyiha fayllari, tarjima fayllari va saytlardagi eski lotin yozuvini topib, yangi (2026) alifboga xavfsiz oʻtkazuvchi vosita.

**RU:** `imlo-lint` находит текст на старой латинице в коде, файлах переводов и на сайтах и безопасно переводит его на новый алфавит 2026 года, не ломая ключи, плейсхолдеры и разметку.

## License

MIT
