A CLDR-compliant slugify function using PyICU
Project description
PyICU Slugify
A CLDR-compliant slugify function using PyICU.
Features
- CLDR-compliant slugification
- Support for multiple languages
- Based on the robust ICU library
Installation
Prerequisites
Before installing PyICU Slugify, you need to have the ICU libraries installed on your system. The installation process varies depending on your operating system.
Ubuntu/Debian
sudo apt-get update
sudo apt-get install libicu-dev
Other Linux Distributions
For other Linux distributions, you'll need to install the ICU development libraries. The package name may vary:
-
Fedora/CentOS/RHEL:
sudo dnf install libicu-devel
-
Arch Linux:
sudo pacman -S icu
-
OpenSUSE:
sudo zypper install libicu-devel
After installing the ICU libraries, you may need to set the ICU_VERSION
environment variable:
export ICU_VERSION=$(pkg-config --modversion icu-i18n)
macOS
Using Homebrew:
brew install icu4c
export CFLAGS=-I/usr/local/opt/icu4c/include
export LDFLAGS=-L/usr/local/opt/icu4c/lib
Windows
- Download the ICU binaries from the official ICU website (http://icu-project.org/download).
- Extract the binaries to a directory (e.g., C:\icu).
- Add the bin folder to your PATH environment variable.
- Set the ICU_ROOT environment variable to the ICU directory.
Installing PyICU Slugify
Once you have the ICU libraries installed, you can install PyICU Slugify using pip:
pip install pyicu-slugify
If you encounter any issues related to PyICU installation, you may need to specify the ICU library path:
pip install --global-option=build_ext --global-option="-I/path/to/icu/include" --global-option="-L/path/to/icu/lib" pyicu-slugify
Replace /path/to/icu/include and /path/to/icu/lib with the appropriate paths on your system.
Usage
Here's a basic example of how to use PyICU Slugify:
from pyicu_slugify import pyicu_slugify
# Basic usage
print(pyicu_slugify("Hello World!")) # Output: hello-world
# Language-specific slugification
print(pyicu_slugify("Über den Wölken", "de")) # Output: uber-den-wolken
Supported Languages
PyICU Slugify supports all languages available in the ICU library. Some commonly used language codes include:
- 'de' for German
- 'fr' for French
- 'es' for Spanish
- 'zh' for Chinese
For a full list of supported language codes, refer to the CLDR language codes (https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.html).
Troubleshooting
If you encounter issues during installation or usage, here are some common problems and solutions:
-
ICU libraries not found: Ensure that the ICU libraries are correctly installed and that the library path is correctly set in your environment variables.
-
Incompatible ICU version: Make sure the installed ICU version is compatible with the PyICU version. You may need to upgrade or downgrade either the ICU libraries or PyICU.
-
Compilation errors: On some systems, you may need to install additional development tools. For example:
On Ubuntu/Debian:
sudo apt-get install build-essential
On Fedora/CentOS/RHEL:
sudo dnf groupinstall "Development Tools"
On macOS:
xcode-select --install
-
Python version compatibility: Ensure you're using a compatible Python version. This package is tested with Python 3.7 and above.
If you continue to experience issues, please open an issue on the GitHub repository with details about your system and the error you're encountering.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyicu_slugify-0.1.1.tar.gz
.
File metadata
- Download URL: pyicu_slugify-0.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
21983c9946c4d2b7bf54d7489b2a0bfda017073ffae4f0d6bbb35e1ff498f928
|
|
MD5 |
24abfb9a14e9ec6e9036917f62c5c267
|
|
BLAKE2b-256 |
b300ffa888685677d11e8184c63c9731c0417592f172709c48b0d26086da589f
|
File details
Details for the file pyicu_slugify-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pyicu_slugify-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
85814e8d51516f2c764413597225e2a86e47e59fbbeae034ae3c516d510e690e
|
|
MD5 |
bf03da67016c89fc733973c60c9c9eb0
|
|
BLAKE2b-256 |
0a9c6329385c7afea6574929cfe936aac32f239b84d29acc51536fa0aa8344e3
|