A simple and lightweight registry library with flexible identifiers and namespaces for Java.
Localize your application cleanly with typed labels, dynamic placeholders, and pluggable serializers.
Explore the docs »
·
Report Bug
·
Request Feature
Table of Contents
i18label4j is a modular Java library for managing localizable text labels with a clean, fluent API. It provides:
- Typed labels: distinguish between locale-aware i18n labels, global labels and immutable literal labels at compile time.
- Placeholder substitution: register static or dynamic
Placeholderobjects on any label and apply them via configurablePlaceholderRulestrategies (supports${key},{key},%key%,<key>, and more out of the box). - Pluggable serializers: convert labels to any target type (plain
String, AdventureComponent, etc.) by registering aLabelSerializer. - Multiple localization sources: load translations from a flat directory
DeepDirSource(supports file, resources, http and more), or implement your ownLocalizationSource. - Format support: JSON, YAML, TOML, and Java
.propertiesfiles are supported out of the box. - Translation caching: the
CommonLabelProvidercaches translations per locale with thread-safeConcurrentHashMapinternals and explicit cache eviction. - Fallback: it supports fallbacks to default or to a fallback string
!{key}or similar
- Java 21+
- Gradle 9+ (wrapper included)
Add the repository and dependency to your build.gradle.kts:
repositories {
maven("https://leycm.github.io/repository/")
}
dependencies {
// API only (compile against the interface)
compileOnly("de.leycm:label4j-api:2.0.0")
// Full implementation (includes CommonLabelProvider, FileSource, DirSource, etc.)
implementation("de.leycm.label4j-impl:2.0.0")
}Or with Maven (pom.xml):
<repository>
<id>leycm-repo</id>
<url>https://leycm.github.io/repository/</url>
</repository>
<dependency>
<groupId>de.leycm</groupId>
<artifactId>label4j-api</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.leycm</groupId>
<artifactId>label4j-impl</artifactId>
<version>2.0.0</version>
</dependency>For Usage and How to start explore the docs
i18label4j
├── i18-api/ # Public API - Label, LabelProvider, Placeholder, PlaceholderRule, LabelSerializer, LocalizationSource
└── i18-impl/ # Implementation - CommonLabelProvider, LiteralLabel, LocaleLabel,
# FileSource, DirSource, FileParser, FileUtils
The library is split into two modules so downstream projects can depend only on the API and swap implementations at runtime via Instanceable.register(...).
- Core
LabelAPI withLiteralLabelandLocaleLabel -
CommonLabelProviderwith thread-safe translation cache -
MappingRulewith 10+ built-in placeholder styles -
FileSourceandDirSourcewith JSON, YAML, TOML,.propertiessupport - Classpath (
resource://), filesystem (file://), and remote (http(s)://) URI schemes - Nested/hierarchical key support in
DirSource - Hot-reload support for translation files
- Maven / Gradle plugin for compile-time key validation
- Additional serializer modules (Adventure, MiniMessage)
See the open issues for the full list of proposed features and known bugs.
Contributions are what make open source such a great place to learn and build. Any contributions you make are greatly appreciated.
- Fork the project
- Create your feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'feat: add some amazing Features') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
Distributed under the GNU Lesser General Public License v3.0. See LICENSE.LGPL for more information.
Lennard — leycm@proton.me
Project Link: https://github.com/leycm/label4j
- Lombok boilerplate-free Java
- SnakeYAML YAML parsing
- toml4j TOML parsing
- org.json JSON parsing
- Adventure API Minecraft text component library
- Best-README-Template README structure inspiration
- Shields.io better readmes