百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

slugify

> 编程语言
开源

用于生成读音 URL 的小型实用程序库。

377 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于生成读音 URL 的小型实用程序库。

Slugify

Description

Small utility library for generating speaking URLs.

Usage Examples

Slugify is published in the Maven Central Repository: Click here

Basic

java
final Slugify slg = Slugify.builder().build();
final String result = slg.slugify("Hello, world!");
// result: hello-world

Underscore Separator

java
final Slugify slg = Slugify.builder().underscoreSeparator(true).build();
final String result = slg.slugify("Hello, world!");
// result: hello_world

Preserve Case

java
final Slugify slg = Slugify.builder().lowerCase(false).build();
final String result = slg.slugify("Hello, world!");
// result: Hello-world

Specifying a Locale

java
final Slugify slg = Slugify.builder().locale(Locale.GERMAN).build();
final String result = slg.slugify("ä");
// result: ae

Built-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.

Custom Replacements

java
// 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-world

Custom replacements take precedence over built-in locale replacements and are applied first.

Transliteration

Requirements

Gradle

There's a feature variant which can be used as follows:

groovy
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.

Other

Manually add the optional dependency com.ibm.icu:icu4j to your project.

Usage Example

java
final Slugify slg = Slugify.builder().transliterator(true).build();
final String result = slg.slugify("Б");
// result: b

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javajavautilutilitiesutility

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言