- Eliminate icu library (20Mb) to use use core features, not intended to be used with non ascii characters.
Small utility library for generating speaking URLs.
Slugify is published in the Maven Central Repository: Click here
final Slugify slg = Slugify.builder().build();
final String result = slg.slugify("Hello, world!");
// result: hello-worldfinal Slugify slg = Slugify.builder().underscoreSeparator(true).build();
final String result = slg.slugify("Hello, world!");
// result: hello_worldfinal Slugify slg = Slugify.builder().lowerCase(false).build();
final String result = slg.slugify("Hello, world!");
// result: Hello-worldfinal Slugify slg = Slugify.builder().locale(Locale.GERMAN).build();
final String result = slg.slugify("ä");
// result: aefinal Slugify slg = Slugify.builder()
// provided as a map
.customReplacements(Map.of("Foo", "Hello", "bar", "world"))
// provided as single key-value
.customReplacement("Foo", "Hello")
.customReplacement("bar", "world")
.build();
final String result = slg.slugify("Foo, bar!");
// result: hello-worldFor 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.
Manually add the optional dependency com.ibm.icu:icu4j to your project.
final Slugify slg = Slugify.builder().transliterator(true).build();
final String result = slg.slugify("Б");
// result: b