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.12"
    }

    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:

NameDepends OnTypeDescription
buildLang-BuildLangTaskRuns 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 NameDefault 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 NameDefault Value
argsLang Builder command line arguments
classpathproject.configurations.langBuilder
main"com.liferay.lang.builder.LangBuilder"

Task Properties

Property NameTypeDefault ValueDescription
excludedLanguageIdsSet<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.
langDirFilenullThe directory where the language properties files are saved. It sets the lang.dir argument.
langFileNameString"Language"The file name prefix of the language properties files (e.g., Language_it.properties). It sets the lang.file argument.
pluginbooleantrueWhether to check for duplicate language keys between the project and the portal. If portalLanguagePropertiesFile is not set, this property has no effect. It sets the lang.plugin argument.
portalLanguagePropertiesFileFilenullThe Language.properties file of the portal. It sets the lang.portal.language.properties.file argument.
translatebooleantrueWhether 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.
translateSubscriptionKeyStringnullThe 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

MethodDescription
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.31"
}
« JSDoc Gradle PluginMaven Plugin Builder Gradle Plugin »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています