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: aeBuilt-in character replacements exist for a subset of locales (see src/main/resources/slugify_*.properties).
For all other locales, no built-in replacements are applied — custom replacements or transliteration
can be used instead.
// provided as single key-value pairs
final Slugify slg = Slugify.builder()
.customReplacement("Foo", "Hello")
.customReplacement("bar", "world")
.build();
// alternatively provided as a map
final Slugify slg = Slugify.builder()
.customReplacements(Map.of("Foo", "Hello", "bar", "world"))
.build();
final String result = slg.slugify("Foo, bar!");
// result: hello-worldCustom replacements take precedence over built-in locale replacements and are applied first.
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 How to Create Feature Variants for a Library in Gradle.
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