Slugify
Description
Small utility library for generating speaking URLs.
Usage Examples
Slugify is published in the Maven Central Repository:
Click here
Basic
final Slugify slg = Slugify.builder().build();
final String result = slg.slugify("Hello, world!");
Underscore Separator
final Slugify slg = Slugify.builder().underscoreSeparator(true).build();
final String result = slg.slugify("Hello, world!");
Case Sensitive
final Slugify slg = Slugify.builder().lowerCase(false).build();
final String result = slg.slugify("Hello, world!");
Specifying a Locale
final Slugify slg = Slugify.builder().locale(Locale.GERMAN).build();
final String result = slg.slugify("ä");
Custom Replacements
final Slugify slg = Slugify.builder()
.customReplacements(Map.of("Foo", "Hello", "bar", "world"))
.customReplacement("Foo", "Hello")
.customReplacement("bar", "world")
.build();
final String result = slg.slugify("Foo, bar!");
Transliteration
Requirements
Gradle 6+
For Gradle 6+ users there's a feature variant which can be used as follows:
capabilities {
requireCapability('com.github.slugify:slugify-transliterator')
}
For more information about feature variants please check the section Modeling feature variants and optional dependencies of gradle's user guide.
Other
Manually add the optional dependency com.ibm.icu:icu4j
to your project.
Usage Example
final Slugify slg = Slugify.builder().transliterator(true).build();
final String result = slg.slugify("Б");