Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/scan-with-sonar/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ runs:
-Dsonar.projectKey=cds-feature-notifications
-Dsonar.projectVersion=${{ steps.get-revision.outputs.REVISION }}
-Dsonar.qualitygate.wait=true
-Dsonar.java.source=17
-Dsonar.java.source=21
-Dsonar.exclusions=**/integration-tests/**
-Dsonar.coverage.jacoco.xmlReportPaths=${{ github.workspace }}/coverage-report/target/site/jacoco-aggregate/jacoco.xml
-Dsonar.coverage.exclusions=**/src/test/**,**/src/gen/**
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Run Spotless
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ jobs:
uses: cap-java/.github/actions/scan-with-codeql@296573b55e906f5c77a1855bcfe4285cbbc5cac4 #main
with:
maven-version: ${{ env.MAVEN_VERSION }}
java-version: '17'
java-version: '21'
language: java-kotlin
queries: security-extended
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy to Maven Central

env:
JAVA_VERSION: '17'
JAVA_VERSION: '21'
MAVEN_VERSION: '3.9.15'

on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: SonarQube Scan
uses: ./.github/actions/scan-with-sonar
with:
java-version: '17'
java-version: '21'
maven-version: ${{ env.MAVEN_VERSION }}
sonarq-token: ${{ secrets.SONARQ_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [17, 21]
java-version: [21, 25]
fail-fast: false
name: Test (Java ${{ matrix.java-version }})

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Version 0.0.2-alpha - 2026-07-14
- Updated cds.services.version to 5.0.0

## Version 0.0.1-alpha - 2026-07-01

Initial release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ private Translations createTranslation(
if (title == null || title.trim().isEmpty()) {
throw new IllegalStateException(
String.format(
"Missing required annotation: @notification.template.title for event '%s'. "
+ "The standalone template API requires a Title to be set.",
event.getName()));
"Missing or unresolved @notification.template.title for event '%s', locale '%s'. "
+ "Ensure the annotation is present and the i18n key exists in your properties file.",
event.getName(), lang));
}
translation.setTitle(title);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ private List<Translations> extractTranslations(CdsEvent event) {
if (displayName == null || displayName.isBlank()) {
throw new IllegalStateException(
String.format(
"Missing required annotation: @notification.template.publicTitle for event '%s'.",
event.getName()));
"Missing or unresolved @notification.template.publicTitle for event '%s', locale '%s'. "
+ "Ensure the annotation is present and the i18n key exists in your properties file.",
event.getName(), locale.toLanguageTag()));
}
translation.setDisplayName(displayName);

Expand All @@ -104,8 +105,9 @@ private List<Translations> extractTranslations(CdsEvent event) {
if (groupTitle == null || groupTitle.isBlank()) {
throw new IllegalStateException(
String.format(
"Missing required annotation: @notification.template.groupedTitle for event '%s'.",
event.getName()));
"Missing or unresolved @notification.template.groupedTitle for event '%s', locale '%s'. "
+ "Ensure the annotation is present and the i18n key exists in your properties file.",
event.getName(), locale.toLanguageTag()));
}
translation.setGroupTitle(groupTitle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class I18nHelper {

private static final Logger logger = LoggerFactory.getLogger(I18nHelper.class);
private static final String I18N_PREFIX = "{i18n>";

private final CdsRuntime runtime;
private EdmxI18nProvider i18nProvider;
Expand Down Expand Up @@ -56,11 +57,16 @@ public Set<Locale> getAvailableLocales() {

/**
* Get locales that have actual notification translations for the given event. Compares each
* locale's resolved {@code notification.template.title} against the English value. If they
* differ, the locale has a real translation and is included. English is always included.
* locale's resolved {@code notification.template.title} against the English value. A locale is
* included only if its title differs from English AND is fully resolved (no unresolved {@code
* {i18n>KEY}} placeholders remain). English is always included.
*
* <p>This filters out locales that only exist because of {@code @sap/cds/common} framework
* translations (e.g. "Created By" in 37 languages) but have no app-specific notification texts.
*
* <p>Note: {@link #resolveI18n(String, java.util.Map)} returns {@code null} when any placeholder
* cannot be resolved. Such locales are excluded to prevent raw placeholder strings from reaching
* ANS.
*/
public Set<Locale> getAvailableLocalesForEvent(CdsEvent event) {
Set<Locale> allLocales = getAvailableLocales();
Expand All @@ -83,7 +89,7 @@ public Set<Locale> getAvailableLocalesForEvent(CdsEvent event) {
Map<String, String> localeTexts = getI18nTexts(locale);
String localeTitle =
resolveAnnotationValue(event, "notification.template.title", localeTexts);
if (!Objects.equals(enTitle, localeTitle)) {
if (localeTitle != null && !Objects.equals(enTitle, localeTitle)) {
filtered.add(locale);
}
}
Expand Down Expand Up @@ -127,16 +133,19 @@ public String resolveAnnotationValue(
* Resolve all {i18n>KEY} patterns in a string using the i18n texts map. Supports both
* single-placeholder values (e.g. "{i18n>TITLE}") and multi-placeholder values (e.g.
* "{i18n>GREETING}, {i18n>BODY}").
*
* @return the resolved string, or {@code null} if any placeholder could not be resolved (i.e. the
* key was not present in {@code i18nTexts})
*/
public String resolveI18n(String value, Map<String, String> i18nTexts) {
if (value == null || !value.contains("{i18n>")) {
if (value == null || !value.contains(I18N_PREFIX)) {
return value;
}

for (Map.Entry<String, String> entry : i18nTexts.entrySet()) {
value = value.replace("{i18n>" + entry.getKey() + "}", entry.getValue());
value = value.replace(I18N_PREFIX + entry.getKey() + "}", entry.getValue());
}
return value;
return value.contains(I18N_PREFIX) ? null : value;
}

/**
Expand Down Expand Up @@ -167,6 +176,10 @@ public String loadHtmlFromClasspath(String filePath, Map<String, String> i18nTex

// Resolve {i18n>KEY} placeholders in the HTML content
String resolvedHtml = resolveI18n(content, i18nTexts);
if (resolvedHtml == null) {
logger.error("Unresolved i18n placeholder(s) in HTML template: {}", filePath);
return null;
}

// Minify HTML: remove comments and unnecessary whitespace
String compactHtml =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ void singlePlaceholder_resolved() {
}

@Test
void unknownKey_notReplaced() {
void unknownKey_returnsNull() {
String input = "{i18n>UNKNOWN_KEY}";
assertEquals(input, i18nHelper.resolveI18n(input, Map.of("SUBTITLE", "Book Order")));
assertNull(i18nHelper.resolveI18n(input, Map.of("SUBTITLE", "Book Order")));
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/.cdsrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"cds": {
"requires": {
"outbox": {
"queue": {
"kind": "persistent-outbox"
}
}
Expand Down
Loading
Loading