Git Product home page Git Product logo

kilt's Introduction

Kilt

Kilt - <strong>K</strong>ilt <strong>I</strong>18n

Kilt I18n L10n and T9n

Easier handling of Java i18n resource bundles.

What is Kilt

Kilt is a set of small tools to ease the handling of Java i18n resource bundles.

It can help by

  • Converting i18n resource bundles to and from XLS(X) sheets for easier translation by a small translation team.

  • Providing a facade to access the entries in a i18n resource bundle statically in a type safe way.

  • Reformat and reorder entries in resource bundles to maintain a constant style and order.

Kilt is available as

  • a standalone CLI application

  • an ant task to be integrated with an ant-based application

  • a maven plugin to be integrated with a maven-based application

Why to use Kilt

The localizations of Java i18n resource bundles are cluttered among serveral files. That’s no problem for software engineers, but not very helpful to translators without the help of additional professional translation tools. Therefore this tool allows to convert the Java i18n resource bundles to a single XLS(X) sheet to be transmitted to the translators. The translators can make their changes directly in the XLS(X) sheet and send it back to the software engineers who incorporate the changes back into the actual Java i18n resource bundles.

Also using Java i18n resource bundles usually involves accessing them by string which is not type safe and requires the knowledge of the exact name of the key to use. Kilt can create a facade to access the resource bundle keys in a type-safe manner. This allows for using code completion in an IDE to find the available keys. It even lists the available translations in the generated Javadoc!

The benefits of Kilt are in short form:

  • Support of a fast and easy translation workflow

  • Minimally invasive changes on import and export of translations (comments, blank lines and order remain intact)

  • Good integration into ant and maven build tools

  • Standalone CLI tool to be used without a build tool

  • Type safe access to translation resources via facade

Usage example

The functionality described above can best be demonstrated by a concrete example. See the Example application for a commented minimal application using Kilts functionality.

Prerequisites

Basic prerequisites

  • Java 8 or higher

To be integrated into an ant build script

When using Java 8 to 10:

  • Apache ant 1.8.1 or higher

When using Java 11+:

  • Apache ant 1.10.6 or higher [1]

To be integrated into a maven build

  • Apache maven 3.0.3 or higher

Installation

Maven plugin

To use the maven plugin of Kilt include the following plugin section in the pom of your project:

  <build>
    <plugins>
      ...
      <plugin>
        <groupId>de.poiu.kilt</groupId>
        <artifactId>kilt-maven-plugin</artifactId>
        <version>1.0.2</version>
        <configuration>
          ...
        </configuration>
        <executions>
          <execution>
            <id>i18n-facade-generation</id>
            <goals>
              <goal>create-facade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    <plugins>
  <build>

See the Kilt User Guide for a detailled description of the available goals and configuration parameters.

Ant task

To use the ant task of Kilt download the kilt-ant package from the Download section and either use the integrated build.xml file or use it as a sample to include it in your own ant build script.

You will need the accompanied properties file and lib directory as well.

As standalone tool

To use Kilt as a standalone tool download the kilt-cli package from the Download section and unpack it to a directory of your choice.

Usage

See the main user guide for a detailled usage description of Kilt.

License

Kilt is licensed under the terms of the Apache license 2.0.

History

Kilt is based on i18n-binder which is apparently orphaned. It started as bugfixes for i18n-binder, but soon involved such massive changes that it was forked into a new project with the new name Kilt.

The current state of Kilt doesn’t share much code with the original anymore.

It provides the following major improvements:

  • The facade generation was recreated from the ground up. The resulting facade is now much simpler, much more concise and easier to use.

  • The commands and parameters are partly renamed (and now extended) to be more concise.

  • XLS(X) files are now updated instead of recreated each time. This allows manual changes to the document (like cell formatting) without losing them after a new export.

  • Empty cells and default resource bundles (without a country code) in the XLS(X) are now supported.

  • An additional command line application was added that does not depend on ant.

  • Another runtime jar was added for using the generated facade in other projects or even have a saner access to resource bundles without any generated facade at all.


1. Older version of ant can be used by exporting the environment variable ANT_OPTS="-Djdk.util.jar.enableMultiRelease=force"

kilt's People

Contributors

hupfdule avatar omnaest avatar dependabot[bot] avatar omeyer-dc avatar koppor avatar

Stargazers

Connor Schweighöfer avatar Ethan McCue avatar Michael Chow avatar solo avatar  avatar Vladimír Kroupa avatar Sam Panza avatar Mihai Bojin avatar Semyon Gaschenko avatar  avatar Zhange avatar Stone Lyu avatar wang avatar Ciaran Liedeman avatar And Sha avatar Roma Averkov avatar Ilia Naryzhny avatar Alexander avatar Vladimir Gurevich avatar Vitaly avatar Vasiliy Bukharev avatar Anton Shelishkevich avatar Maxim Sashkin avatar Oleh Kurpiak avatar Art avatar  avatar Pelmegov Stepan avatar Vyacheslav Rusakov avatar Oleg Chirukhin avatar Joe avatar abbie avatar David Watkins avatar Christopher Speck avatar Suresh avatar Nuno avatar Paulius Paplauskas avatar Francois Marot avatar Jonas Groß avatar

Watchers

Jonas Groß avatar James Cloos avatar Yuri Orlov avatar  avatar  avatar

kilt's Issues

Explain parameter usage

The documentation does not bring clarity how to use parameterized messages

Example:

Added\ group\ "%0".=Added group "%0".

Then, i18n.get(Msg.ADDED_GROUP_0, theGroupName) can be used to generate the localized message.

If it it not implemented yet, I would voite for using {} as place holder.

Note: We use the full (!) English message as key to ensure that the Java code is clear w.r.t. concrete message. Maybe, we could change that, but we were successful since approximately 10 years with that. [Details]

Provide command to reformat .properties files

It would be helpful if a command to reformat .properties files would be provided.

The command should allow reformatting and reordering.

Reformatting should reformat according to a standard or given format string.

Reordering should allow lexicographical reordering by the name of the keys and also by ordering the keys of one .properties file according to the order in another .properties file.

NPE when importing an XLSX that was written by LibreOffice

When opening an XLSX file (that could be correctly imported by kilt) in LibreOffice and writing it again without doing any changes a NullPointerException occurs sometimes.

The attached example file triggers this bug.
libreoffice_nullValues.xlsx

The following stacktrace was created with kilt-cli:

Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (de.poiu.kilt.cli.KiltImportXls@62d773): java.lang.NullPointerException                                                                                                              
  at picocli.CommandLine.execute(CommandLine.java:914)
  at picocli.CommandLine.access$700(CommandLine.java:104)
  at picocli.CommandLine$RunLast.handle(CommandLine.java:1083)
  at picocli.CommandLine$RunLast.handle(CommandLine.java:1051)
  at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:959)
  at picocli.CommandLine.parseWithHandlers(CommandLine.java:1242)
  at picocli.CommandLine.run(CommandLine.java:1701)
  at picocli.CommandLine.run(CommandLine.java:1647)
  at de.poiu.kilt.cli.Kilt.main(Kilt.java:65)
Caused by: java.lang.NullPointerException
  at de.poiu.kilt.internal.xls.XlsFile.init(XlsFile.java:196)
  at de.poiu.kilt.internal.xls.XlsFile.<init>(XlsFile.java:90)
  at de.poiu.kilt.internal.XlsImExporter.importXls(XlsImExporter.java:67)
  at de.poiu.kilt.cli.KiltImportXls.run(KiltImportXls.java:91)
  at picocli.CommandLine.execute(CommandLine.java:906)
  ... 8 more

basename of generated facade enum seems to be incorrect sometimes

For the file src/main/resources/i18n/errors.properties and the following
maven plugin configuration:

<plugin>
  <groupId>de.poiu.kilt</groupId>
  <artifactId>kilt-maven-plugin</artifactId>
  <version>1.0.0</version>
  <configuration>
    <propertiesRootDirectory>src/main/resources/i18n</propertiesRootDirectory>
    <i18nIncludes>**/*.properties</i18nIncludes>
    <propertyFileEncoding>ISO-8859-1</propertyFileEncoding>
  </configuration>
  <executions>
    <!-- This execution builds the I18n facade in the
    code-generation phase. -->
    <execution>
      <id>i18n-facade-generation</id>
      <goals>
        <goal>create-facade</goal>
      </goals>
    </execution>
  </executions>
</plugin>

the following is generated in the i18n.generated.Errors enum class:

  private static final String BASENAME = ".errors";

The leading dot is very likely wrong

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.