Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] manifestCreator: set fallbackLocale to empty string if no locale is present #962

Merged
merged 4 commits into from
Dec 12, 2023
Merged
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
4 changes: 3 additions & 1 deletion lib/processors/manifestCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,11 @@ async function createManifest(

const supportedLocalesArray = Array.from(supportedLocales);
supportedLocalesArray.sort();

return {
bundleUrl: i18n,
supportedLocales: supportedLocalesArray
supportedLocales: supportedLocalesArray,
fallbackLocale: supportedLocalesArray.length === 1 ? supportedLocalesArray[0] : undefined
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<appData>
<manifest xmlns="http://www.sap.com/ui5/buildext/manifest">
<i18n>(i18nPathRelativeToLibrary)</i18n>
<i18n>i18nf/custommessagebundle.properties</i18n>
<offline>false</offline>
<deviceTypes desktop="true" phone="true" tablet="true" />
<supportedTheme>sap_belize</supportedTheme>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mytext=Hello

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
"id": "library.i",
"type": "library",
"embeds": [],
"i18n": "(i18nPathRelativeToLibrary)",
"i18n": {
"bundleUrl": "i18nf/custommessagebundle.properties",
"supportedLocales": [
""
],
"fallbackLocale": ""
},
"applicationVersion": {
"version": "1.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<appData>
<manifest xmlns="http://www.sap.com/ui5/buildext/manifest">
<i18n>(i18nPathRelativeToLibrary)</i18n>
<i18n>i18nf/custommessagebundle.properties</i18n>
<offline>false</offline>
<deviceTypes desktop="true" phone="true" tablet="true" />
<supportedTheme>sap_belize</supportedTheme>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mytext=Hello
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
"id": "library.i",
"type": "library",
"embeds": [],
"i18n": "(i18nPathRelativeToLibrary)",
"i18n": {
"bundleUrl": "i18nf/custommessagebundle.properties",
"supportedLocales": [
""
],
"fallbackLocale": ""
},
"applicationVersion": {
"version": "1.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<appData>
<manifest xmlns="http://www.sap.com/ui5/buildext/manifest">
<i18n>(i18nPathRelativeToLibrary)</i18n>
<i18n>i18nf/custommessagebundle.properties</i18n>
<offline>false</offline>
<deviceTypes desktop="true" phone="true" tablet="true" />
<supportedTheme>sap_belize</supportedTheme>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mytext=Hello
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
"id": "library.i",
"type": "library",
"embeds": [],
"i18n": "(i18nPathRelativeToLibrary)",
"i18n": {
"bundleUrl": "i18nf/custommessagebundle.properties",
"supportedLocales": [
""
],
"fallbackLocale": ""
},
"applicationVersion": {
"version": "1.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/library.i/main/src/library/i/.library
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<appData>
<manifest xmlns="http://www.sap.com/ui5/buildext/manifest">
<i18n>(i18nPathRelativeToLibrary)</i18n>
<i18n>i18nf/custommessagebundle.properties</i18n>
<offline>false</offline>
<deviceTypes desktop="true" phone="true" tablet="true" />
<supportedTheme>sap_belize</supportedTheme>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mytext=Hello
155 changes: 152 additions & 3 deletions test/lib/tasks/generateLibraryManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ test("integration: Library with i18n bundle file (messagebundle.properties)", as
library: {
i18n: {
bundleUrl: "messagebundle.properties",
supportedLocales: [""]
supportedLocales: [""],
fallbackLocale: ""
}
}
},
Expand Down Expand Up @@ -214,7 +215,154 @@ test("integration: Library with i18n=true declared in .library", async (t) => {
library: {
i18n: {
bundleUrl: "messagebundle.properties",
supportedLocales: [""]
supportedLocales: [""],
fallbackLocale: ""
}
}
},
});
});

test("integration: Library with i18n=true declared in .library and multiple locales", async (t) => {
t.context.workspace = createWorkspace();

t.context.resources = [];
t.context.resources.push(createResource({
path: "/resources/test/lib/.library",
string: `
<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >

<name>test.lib</name>
<vendor>SAP SE</vendor>
<copyright></copyright>
<version>2.0.0</version>

<documentation>Test Lib</documentation>

<appData>
<manifest xmlns="http://www.sap.com/ui5/buildext/manifest">
<sap.ui5>
<library>
<i18n>true</i18n>
</library>
</sap.ui5>
</manifest>
</appData>

</library>
`,
project: t.context.workspace._project
}));

t.context.resources.push(createResource({
path: "/resources/test/lib/messagebundle.properties",
project: t.context.workspace._project
}));

t.context.resources.push(createResource({
path: "/resources/test/lib/messagebundle_en.properties",
project: t.context.workspace._project
}));

await assertCreatedManifest(t, {
"_version": "1.21.0",
"sap.app": {
applicationVersion: {
version: "2.0.0",
},
description: "Test Lib",
embeds: [],
id: "test.lib",
offline: true,
resources: "resources.json",
title: "Test Lib",
type: "library",
},
"sap.ui": {
supportedThemes: [],
technology: "UI5",
},
"sap.ui5": {
dependencies: {
libs: {},
minUI5Version: "1.0",
},
library: {
i18n: {
bundleUrl: "messagebundle.properties",
supportedLocales: ["", "en"]
}
}
},
});
});

test("integration: Library with i18n=true declared in .library and single locale", async (t) => {
t.context.workspace = createWorkspace();

t.context.resources = [];
t.context.resources.push(createResource({
path: "/resources/test/lib/.library",
string: `
<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >

<name>test.lib</name>
<vendor>SAP SE</vendor>
<copyright></copyright>
<version>2.0.0</version>

<documentation>Test Lib</documentation>

<appData>
<manifest xmlns="http://www.sap.com/ui5/buildext/manifest">
<sap.ui5>
<library>
<i18n>true</i18n>
</library>
</sap.ui5>
</manifest>
</appData>

</library>
`,
project: t.context.workspace._project
}));

t.context.resources.push(createResource({
path: "/resources/test/lib/messagebundle_de.properties",
project: t.context.workspace._project
}));

await assertCreatedManifest(t, {
"_version": "1.21.0",
"sap.app": {
applicationVersion: {
version: "2.0.0",
},
description: "Test Lib",
embeds: [],
id: "test.lib",
offline: true,
resources: "resources.json",
title: "Test Lib",
type: "library",
},
"sap.ui": {
supportedThemes: [],
technology: "UI5",
},
"sap.ui5": {
dependencies: {
libs: {},
minUI5Version: "1.0",
},
library: {
i18n: {
bundleUrl: "messagebundle.properties",
supportedLocales: ["de"],
fallbackLocale: "de"
}
}
},
Expand Down Expand Up @@ -345,7 +493,8 @@ test("integration: Library with i18n=foo.properties declared in .library", async
library: {
i18n: {
bundleUrl: "foo.properties",
supportedLocales: [""]
supportedLocales: [""],
fallbackLocale: ""
}
}
},
Expand Down
Loading