Skip to main content

A Romaji/Kana conversion library

Project description

romkan2

romkan2 is a modernized, actively maintained fork of python-romkan, designed as a drop-in replacement for the original library.

This is a Romaji/Kana conversion library for Python, which is used to convert a Japanese Romaji (ローマ字) string to a Japanese Kana (仮名) string or vice versa.

Why romkan2?

The original python-romkan by Mort Yao has not been actively maintained in recent years. This fork aims to:

  • Support modern Python versions (3.9+)
  • Modernize the codebase with type hints and improved code structure
  • Use contemporary Python packaging standards (pyproject.toml)
  • Maintain full backward compatibility as a drop-in replacement

Heritage

This library is the Pythonic port of Ruby/Romkan, originally authored by Satoru Takabayashi and ported by Masato Hagiwara, then modernized by Mort Yao.

romkan2 handles both Katakana (片仮名) and Hiragana (平仮名) with the Hepburn (ヘボン式) romanization system, as well as the modern Kunrei-shiki (訓令式) romanization system.

Installation

Install via pip:

pip install romkan2

Or install from source:

git clone https://github.com/altescy/romkan2.git
cd romkan2
pip install -e .

Usage

import romkan

# Convert Kana to Romaji
print(romkan.to_roma("にんじゃ"))
# => ninja

print(romkan.to_hepburn("にんじゃ"))
# => ninja

print(romkan.to_kunrei("にんじゃ"))
# => ninzya

# Convert Romaji to Kana
print(romkan.to_hiragana("ninja"))
# => にんじゃ

print(romkan.to_katakana("ninja"))
# => ニンジャ

API Reference

to_katakana(string: str) -> str

Convert a Romaji (ローマ字) to a Katakana (片仮名).

to_hiragana(string: str) -> str

Convert a Romaji (ローマ字) to a Hiragana (平仮名).

to_kana(string: str) -> str

Convert a Romaji (ローマ字) to a Katakana (片仮名). (same as to_katakana)

to_hepburn(string: str) -> str

Convert a Kana (仮名) or a Kunrei-shiki Romaji (訓令式ローマ字) to a Hepburn Romaji (ヘボン式ローマ字).

to_kunrei(string: str) -> str

Convert a Kana (仮名) or a Hepburn Romaji (ヘボン式ローマ字) to a Kunrei-shiki Romaji (訓令式ローマ字).

to_roma(string: str) -> str

Convert a Kana (仮名) to a Hepburn Romaji (ヘボン式ローマ字).

Migration from python-romkan

romkan2 is a drop-in replacement for python-romkan. Simply replace:

# Old
import romkan

# New
import romkan2 as romkan

The package name is different (romkan2), but the module name remains romkan for full backward compatibility.

License

romkan2 is licensed under the BSD license.

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

romkan2-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

romkan2-0.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file romkan2-0.1.0.tar.gz.

File metadata

  • Download URL: romkan2-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for romkan2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a15759391d75294148ad02c62c245d43656ade24dd9489d6799b6451daa38f8e
MD5 d290650675ea8a55e7de0cca5bb6148c
BLAKE2b-256 1fb6387c28866c0fe3f49ae2c3a41136cb8f854a1bb5dc5d39d8bf834dbed677

See more details on using hashes here.

File details

Details for the file romkan2-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: romkan2-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for romkan2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4881019f58bed360fc4c47f283e69371dbf3c2b50269fbab0a0442dbccdf83f5
MD5 8d4d008bc14b9753ab1d85bbc6330013
BLAKE2b-256 e22e69be1a1e57d033f1ac202668b2bcb0a52d40f27c81b511d3465fe1a454ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page