trkit

Turkish text utilities and Türkiye-specific validators. A Python package — usable as a library or a command line tool.

$ pip install trkit
PyPI GitHub MIT licence Python 3.10+

The problem it solves

Python's built-in upper() and lower() follow English rules. They do not know about the Turkish dotted/dotless i distinction — so they quietly corrupt city names, personal names and search queries.

✗ Plain Python

"istanbul".upper()→ISTANBUL
"IĞDIR".lower()→iğdir
"izmir".title()→Izmir

✓ With trkit

upper("istanbul")→İSTANBUL
lower("IĞDIR")→ığdır
title("izmir")→İzmir

Try it live

Type into the boxes below — results update as you type. This is everything the package does.

Text utilities

Type anything and see the output of all five functions at once.

upper()
lower()
title()
asciify()
slugify()

National ID (TCKN)

11 digits, checksum validation. Handy in form validation.

Waiting for a number

IBAN validation

Türkiye IBAN, ISO 13616 mod-97 check. Spaces are ignored.

Waiting for an IBAN

Plate code ↔ province

Type a code to get the province (35), or a province to get the code (İzmir). All 81 provinces included.

—
enter a code or a province name

How to use it

Two ways: from inside your own Python code, or straight from the terminal.

# install first:  pip install trkit
from trkit import upper, lower, title, slugify, asciify
from trkit import is_valid_tckn, is_valid_iban
from trkit import city_from_plate, plate_from_city

upper("istanbul")                 # 'İSTANBUL'
lower("IĞDIR")                    # 'ığdır'
title("izmir kuş cenneti")        # 'İzmir Kuş Cenneti'
asciify("Çiğdem Şahin")            # 'Cigdem Sahin'
slugify("Çığır Açan Şeyler")      # 'cigir-acan-seyler'

is_valid_tckn("10000000146")       # True
is_valid_iban("TR33 0006 1005 1978 6457 8413 26")  # True

city_from_plate(35)               # 'İzmir'
plate_from_city("İSTANBUL")         # 34