diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml
index 3705306..650cecd 100644
--- a/.github/workflows/sonarcloud.yml
+++ b/.github/workflows/sonarcloud.yml
@@ -4,13 +4,9 @@ on:
push:
branches:
- main
- - stage
- - dev
- snapshot/*
- release/*
- # pull_request:
- # types: [opened, synchronize, reopened]
- workflow_dispatch:
+# workflow_dispatch:
jobs:
build:
name: Build and analyze
@@ -58,4 +54,4 @@ jobs:
-Dsonar.exclusions=${{ vars.SONAR_EXCLUSIONS }} \
-Dsonar.java.binaries=${{ vars.SONAR_JAVA_BINARIES }} \
-Dsonar.coverage.exclusions=${{ vars.SONAR_COVERAGE_EXCLUSIONS }} \
- -Dsonar.java.source=${{ vars.SONAR_JAVA_SOURCE }}
+ -Dsonar.java.source=17
diff --git a/README.md b/README.md
index 511af56..a3a15e9 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
This package provides a [MessageSource](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/MessageSource.html) for using translations from XLIFF files. The package support XLIFF versions 1.2, 2.0 and 2.1.
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=alaugks_spring-xliff-translation&metric=alert_status)](https://sonarcloud.io/summary/overall?id=alaugks_spring-xliff-translation)
-[![Maven Central](https://img.shields.io/maven-central/v/io.github.alaugks/spring-messagesource-xliff.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/io.github.alaugks/spring-messagesource-xliff/1.3.0)
+[![Maven Central](https://img.shields.io/maven-central/v/io.github.alaugks/spring-messagesource-xliff.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/io.github.alaugks/spring-messagesource-xliff/2.0.0)
## Dependency
@@ -12,59 +12,59 @@ This package provides a [MessageSource](https://docs.spring.io/spring-framework/
io.github.alaugksspring-messagesource-xliff
- 1.3.0
+ 2.0.0
```
### Gradle
```text
-implementation group: 'io.github.alaugks', name: 'spring-messagesource-xliff', version: '1.3.0'
+implementation group: 'io.github.alaugks', name: 'spring-messagesource-xliff', version: '2.0.0'
```
-### Snapshots
-
-| Version | Description |
-|:---------------|:------------------------------------------------------------------------------------------|
-| 2.0.0-SNAPSHOT | [SNAPSHOT](https://github.com/alaugks/spring-messagesource-xliff/tree/snapshot/2.0.0) | |
-
## MessageSource Configuration
The class XliffTranslationMessageSource implements the [MessageSource](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/MessageSource.html) interface.
-### XliffTranslationMessageSource
+`builder(Locale defaultLocale, String locationPattern)` or
+`builder(Locale defaultLocale, List locationPatterns)` (***required***)
+* Argument `Locale locale`: Defines the default locale.
+* Argument `String locationPattern` | `List locationPatterns`:
+ * Defines the pattern used to select the XLIFF files.
+ * The package uses the [PathMatchingResourcePatternResolver](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/support/PathMatchingResourcePatternResolver.html) to select the XLIFF files. So you can use the supported patterns.
+ * Files with the extension `xliff` and `xlf` are filtered from the result list.
-`setBasenamePattern(String basename)` or `setBasenamesPattern(Iterable basenames)` (***required***)
+`defaultDomain(String defaultDomain)`
-* Defines the pattern used to select the XLIFF files.
-* The package uses the [PathMatchingResourcePatternResolver](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/support/PathMatchingResourcePatternResolver.html) to select the XLIFF files. So you can use the supported patterns.
-* Files with the extension `xliff` and `xlf` are filtered from the result list.
+* Defines the default domain. Default is `messages`. For more information, see [XlIFF Translations Files](#xliff-translation-files).
-`setDefaultLocale(Locale locale)` (***required***)
-* Defines the default language.
-`setDefaultDomain(String defaultDomain)`
-* Defines the default domain. Default is `messages`. For more information, see [XlIFF Translations Files](#xliff).
+### Example
+
+* Default locale is `en`.
+* The Xliff files are stored in `src/main/resources/translations`.
```java
-import de.alaugks.spring.XliffTranslationMessageSource;
+import io.github.alaugks.spring.messagesource.xliff.XliffResourceMessageSource;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-
import java.util.Locale;
@Configuration
public class MessageConfig {
-
+
+ @Bean
public MessageSource messageSource() {
- XliffTranslationMessageSource messageSource = new XliffTranslationMessageSource();
- messageSource.setDefaultLocale(Locale.forLanguageTag("en"));
- messageSource.setBasenamePattern("translations/*");
- return messageSource;
+ return XliffResourceMessageSource
+ .builder(
+ Locale.forLanguageTag("en"),
+ "translations/*"
+ )
+ .build();
}
-
+
}
```
@@ -77,10 +77,12 @@ public class MessageConfig {
* **XLIFF 1.2**:
* If the attribute `resname` does not exist, the attribute `id` is used to determine the identifier.
* Documentation identifier: [XLIFF 1.2](http://docs.oasis-open.org/xliff/v1.2/xliff-profile-html/xliff-profile-html-1.2.html#General_Identifiers)
- * XLIFF 2.*:
+ * **XLIFF 2.***:
* The attribute `id` is optional by standard in XLIFF 2.*. However, this package requires the `id` on a translation unit.
* Documentation identifier: [XLIFF 2.0](https://docs.oasis-open.org/xliff/xliff-core/v2.0/csprd01/xliff-core-v2.0-csprd01.html#segment) and [XLIFF 2.1](https://docs.oasis-open.org/xliff/xliff-core/v2.1/os/xliff-core-v2.1-os.html#segment)
-* For performance reasons, there is no validation of XLIFF files with an XMLSchema. If there is any corrupt XML in an XLIFF file, the SAX parser will throw a [Fatal Error].
+* All attributes in the `` tag are ignored.
+* For performance reasons, there is no validation of XLIFF files with an XMLSchema.
+* SAX parser errors are handled by an [ErrorHandler](src/main/java/io/github/alaugks/spring/messagesource/xliff/exception/SaxErrorHandler.java).
### Structure of the Translation Filename
@@ -133,14 +135,6 @@ Mixing XLIFF versions is possible. Here is an example using XLIFF 1.2 and XLIFF
Postcode
-
-
- Your email {0} has been registered.
-
-
-
- This is a default message.
-