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 romkan2

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

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

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

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

print(romkan2.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

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.1.tar.gz (7.8 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.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for romkan2-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f05667dd6f91ea06e1aee918ce788fede25b78bc2158ddefe6e3d15b55647589
MD5 661b17fa6b415ce3f9d9c2eeb47c4b04
BLAKE2b-256 a57d34af470e515e86cd9270fe565f4a9c5e84ddb9fd19c4f2c9fcee2e215dca

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for romkan2-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a19f7f420eef384b214befc47ec0bef2722cf6fcc8c6cc66abf903fa343bbef
MD5 80bf9f286b27f957445c2e5f6b9750a6
BLAKE2b-256 5e130e1f09f24b04e146ea0074c9f94c5de3b54492bdeb22172323dfd5975602

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