This is a direct port of the maven plugin for the native2ascii tool provided as part of the JDK
Add the plugin to your Plugins.scala within your project:
import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val native2ascii = "eu.getintheloop" % "sbt-native2ascii-plugin" % "0.1.0"
}
…and then mix the Native2Ascii trait into your project:
class SampleProject(info: ProjectInfo) extends DefaultWebProject(info) with Native2AsciiPlugin {
...
}
Ensure you have all your localization .txt files in src/main/i18n and by default they will be translated into your application resources folder in src/main/resources.
Then, from your SBT prompt just hit:
> native2ascii
All being well you should then see something like:
[info] == native2ascii ==
[info] Encoding '.txt' to '.properties' file(s) in src/main/resources
[info] Translation complete.
[info] == native2ascii ==
Override any of the following methods to change the default behaviour:
By default this plugin expects your input translation files to be UTF-8 encoded. Change this setting to affect the encoding passed to native2ascii
def encoding: String = "UTF-8"
Where should native2ascii look for you r
def translationInputPath: Path = mainSourcePath / "i18n"
The file extension of your input translation texts (the ones located in translationInputPath)
def translationInputExtension: String = "txt"
The file location to place the escaped translation files
def translationOutputPath: Path = mainResourcesPath
The file extension of your output translations
def translationOutputExtension: String = "properties"