Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
.lfrbuild-semantic-versioning
CHANGELOG.markdown
README.markdown
bnd.bnd
build.gradle

README.markdown

Lang Builder Gradle Plugin

The Lang Builder Gradle plugin lets you run the Liferay Lang Builder tool to sort and translate the language keys in your project.

The plugin has been successfully tested with Gradle 4.10.2.

Usage

To use the plugin, include it in your build script:

buildscript {
	dependencies {
		classpath group: "com.liferay", name: "com.liferay.gradle.plugins.lang.builder", version: "3.0.6"
	}

	repositories {
		maven {
			url "https://repository-cdn.liferay.com/nexus/content/groups/public"
		}
	}
}

apply plugin: "com.liferay.lang.builder"

Since the plugin automatically resolves the Liferay Lang Builder library as a dependency, you have to configure a repository that hosts the library and its transitive dependencies. The Liferay CDN repository hosts them all:

repositories {
	maven {
		url "https://repository-cdn.liferay.com/nexus/content/groups/public"
	}
}

See this page on the Liferay Developer Network for more information about usage of the Lang Builder Gradle plugin.

Tasks

The plugin adds one task to your project:

Name Depends On Type Description
buildLang - BuildLangTask Runs Liferay Lang Builder to translate language property files.

The buildLang task is automatically configured with sensible defaults, depending on whether the java plugin is applied:

Property Name Default Value
langDir

If the java plugin is applied: The directory content in the first resources directory of the main source set (by default: src/main/resources/content).

Otherwise: null

BuildLangTask

Tasks of type BuildLangTask extend JavaExec, so all its properties and methods, such as args and maxHeapSize, are available. They also have the following properties set by default:

Property Name Default Value
args Lang Builder command line arguments
classpath project.configurations.langBuilder
main "com.liferay.lang.builder.LangBuilder"

Task Properties

Property Name Type Default Value Description
excludedLanguageIds Set<String> ["da", "de", "fi", "ja", "nl", "pt_PT", "sv"] The language IDs to exclude in the automatic translation. It sets the lang.excluded.language.ids argument.
langDir File null The directory where the language properties files are saved. It sets the lang.dir argument.
langFileName String "Language" The file name prefix of the language properties files (e.g., Language_it.properties). It sets the lang.file argument.
translate boolean true Whether to translate the language keys and generate a language properties file for each locale that's supported by Liferay. It sets the lang.translate argument.
translateSubscriptionKey String null The subscription key for Microsoft Translation integration. Subscription to the Translator Text Translation API on Microsoft Cognitive Services is required. Basic subscriptions, up to 2 million characters a month, are free. See here for more information. It sets the lang.translate.subscription.key argument.

The properties of type File support any type that can be resolved by project.file. Moreover, it is possible to use Closures and Callables as values for the String properties, to defer evaluation until task execution.

Task Methods

Method Description
BuildLangTask excludedLanguageIds(Iterable<Object> excludedLanguageIds) Adds language IDs to exclude in the automatic translation.
BuildLangTask excludedLanguageIds(Object... excludedLanguageIds) Adds language IDs to exclude in the automatic translation.

Additional Configuration

There are additional configurations that can help you use the Lang Builder.

Liferay Lang Builder Dependency

By default, the plugin creates a configuration called langBuilder and adds a dependency to the latest released version of the Liferay Lang Builder. It is possible to override this setting and use a specific version of the tool by manually adding a dependency to the langBuilder configuration:

dependencies {
	langBuilder group: "com.liferay", name: "com.liferay.lang.builder", version: "1.0.29"
}
You can’t perform that action at this time.