mirror of
https://github.com/nitu2003/T18n
synced 2024-11-21 07:08:46 +00:00
轻量级开源本地化库
https://github.com/nitu2003/T18n
|
||
---|---|---|
.github/workflows | ||
gradle/wrapper | ||
src/main/java/cn/glycol/t18n | ||
.gitignore | ||
build.gradle | ||
gradlew | ||
gradlew.bat | ||
README.md | ||
settings.gradle |
Taskeren's Internationalization
A lightweight, powerful I18n tool for Java.
Get T18n
You can get this project in Jitpack with Maven, Gradle and so on.
Maven
- Import the Jitpack source.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
- Add the denpendency.
<dependency>
<groupId>com.github.nitu2003</groupId>
<artifactId>T18n</artifactId>
<version>1.5</version>
</dependency>
Gradle
- Import the Jitpack source.
repositories {
...
maven { url 'https://jitpack.io' }
}
- Add the dependency.
dependencies {
implementation 'com.github.nitu2003:T18n:1.5'
}
For else
Dev with T18n
- Get the Language Map.
// from file
LanguageMapBuilder.fromFile(new File("res/i18n/en_us.lang"));
// from jar resource
LanguageMapBuilder.fromJarResource("res/i18n/en_us.lang");
// from online content (Deprecated)
LanguageMapBuilder.fromURL("https://example.com/i18n/en.lang");
- Push it to the I18n.
// reset the I18n and push it
T18n.set(theMap);
// add the new to the old
T18n.add(theMap);
- Use it in the project en.lang
HelloToUser=Hello %s.
app.java
System.out.println(I18n.format("HelloToUser", "Taskeren")); // It should be "Hello Taskeren"