轻量级开源本地化库 https://github.com/nitu2003/T18n

Taskeren bf55d38a7b 修改方法位置 1 month ago
.github 7e91fa3d4c 添加CI支持 2 months ago
gradle 5b058e8d58 v1.0 4 months ago
src bf55d38a7b 修改方法位置 1 month ago
.gitignore b9d5915cda 调整部分方法 2 months ago
README.md bf55d38a7b 修改方法位置 1 month ago
build.gradle 5b058e8d58 v1.0 4 months ago
gradlew 1625253fca 给予Gradlew执行权限 2 months ago
gradlew.bat 5b058e8d58 v1.0 4 months ago
settings.gradle 5b058e8d58 v1.0 4 months ago

README.md

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

  1. Import the Jitpack source.

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    
  2. Add the denpendency.

    <dependency>
        <groupId>com.github.nitu2003</groupId>
        <artifactId>T18n</artifactId>
        <version>1.5</version>
    </dependency>
    

Gradle

  1. Import the Jitpack source.

    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
    
  2. Add the dependency.

    dependencies {
        implementation 'com.github.nitu2003:T18n:1.5'
    }
    

For else

Dev with T18n

  1. 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");
    
  2. Push it to the I18n.

    // reset the I18n and push it
    T18n.set(theMap);
    // add the new to the old
    T18n.add(theMap);
    
  3. Use it in the project en.lang

    HelloToUser=Hello %s.
    

    app.java

    System.out.println(I18n.format("HelloToUser", "Taskeren")); // It should be "Hello Taskeren"