Welcome to pylatinize, a lightweight, open-source Python library designed for transliterating and normalizing Unicode text to Latin ASCII. This library provides configurable mappings and supports various Unicode normalization forms. Whether you are dealing with accented characters, diacritics, or even emojis, pylatinize simplifies the process of converting them into a more manageable ASCII format.
- Transliteration: Convert Unicode text to Latin ASCII.
- Normalization: Supports various Unicode normalization forms.
- Configurable Mappings: Customize the way characters are transliterated.
- Lightweight: Minimal dependencies for easy integration into your projects.
- Open Source: Freely available for use and modification.
To install pylatinize, you can use pip. Run the following command in your terminal:
pip install pylatinizeYou can also download the latest release from our Releases page and follow the instructions provided there.
Using pylatinize is straightforward. Here’s a simple example to get you started:
from pylatinize import Latinizer
text = "Café naïve résumé"
latinized_text = Latinizer().transliterate(text)
print(latinized_text) # Output: Cafe naive resumeIn this example, the library automatically removes diacritics and converts accented characters to their ASCII equivalents.
You can customize the transliteration process by providing your own mappings. Here’s how you can do it:
from pylatinize import Latinizer
custom_mappings = {
'é': 'e',
'ñ': 'n',
'ç': 'c',
}
latinizer = Latinizer(mappings=custom_mappings)
text = "Café naïve résumé"
latinized_text = latinizer.transliterate(text)
print(latinized_text) # Output: Cafe naive resumeThis feature allows you to tailor the library to meet your specific needs.
Here are some more examples to illustrate the capabilities of pylatinize:
text = "Jalapeño"
latinized_text = Latinizer().transliterate(text)
print(latinized_text) # Output: Jalapenotext = "I love 🍕 and ☕!"
latinized_text = Latinizer().transliterate(text)
print(latinized_text) # Output: I love and !custom_mappings = {
'ü': 'u',
'ö': 'o',
}
latinizer = Latinizer(mappings=custom_mappings)
text = "Fünf über alles"
latinized_text = latinizer.transliterate(text)
print(latinized_text) # Output: Funf uber allesWe welcome contributions to pylatinize! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-branch). - Open a Pull Request.
Please ensure that your code adheres to the existing style and includes tests for any new features.
pylatinize is licensed under the MIT License. See the LICENSE file for more details.
For questions or feedback, please open an issue on the GitHub repository or contact the maintainers directly.
You can find the latest releases and updates on our Releases page.
Thank you for checking out pylatinize! We hope you find it useful for your projects.