diff --git a/lib/processors/manifestCreator.js b/lib/processors/manifestCreator.js index 948228f69..09f00c27c 100644 --- a/lib/processors/manifestCreator.js +++ b/lib/processors/manifestCreator.js @@ -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 }; } diff --git a/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/.library b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/.library index 4ef9fffe7..acfb88eed 100644 --- a/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/.library +++ b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/.library @@ -21,7 +21,7 @@ - (i18nPathRelativeToLibrary) + i18nf/custommessagebundle.properties false sap_belize diff --git a/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/i18nf/custommessagebundle.properties b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/i18nf/custommessagebundle.properties new file mode 100644 index 000000000..dbb825dab --- /dev/null +++ b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/i18nf/custommessagebundle.properties @@ -0,0 +1 @@ +mytext=Hello \ No newline at end of file diff --git a/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/library-preload.js b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/library-preload.js index 6528441b9..793378555 100644 --- a/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/library-preload.js +++ b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/library-preload.js @@ -4,6 +4,6 @@ */ sap.ui.predefine("library/i/library", ["sap/ui/core/Core"],function(i){"use strict";sap.ui.getCore().initLibrary({name:"library.i",version:"1.0.0",dependencies:["sap.ui.core"],types:["library.i.ButtonType","library.i.DialogType"],interfaces:["library.i.IContent"],controls:["library.i.Button","library.i.CheckBox","library.i.Dialog","library.i.Input","library.i.Label","library.i.Link","library.i.Menu","library.i.Text"],elements:["library.i.MenuItem"]});return thisLib}); sap.ui.require.preload({ - "library/i/manifest.json":'{"_version":"1.21.0","sap.app":{"id":"library.i","type":"library","embeds":[],"i18n":"(i18nPathRelativeToLibrary)","applicationVersion":{"version":"1.0.0"},"title":"{{title}}","description":"{{description}}","ach":"NOT-ME","resources":"resources.json","offline":false,"openSourceComponents":[{"name":"D3.js","packagedWithMySelf":false},{"name":"Hammer.js","packagedWithMySelf":true,"version":"2.0.4"}]},"sap.ui":{"technology":"UI5","deviceTypes":{"desktop":true,"tablet":true,"phone":true},"supportedThemes":[]},"sap.ui5":{"dependencies":{"minUI5Version":"1.0","libs":{"sap.ui.core":{"minVersion":"1.0.0"},"library.d":{"lazy":true}}},"contentDensities":{"cozy":true,"compact":false},"library":{"i18n":false,"content":{"controls":["library.i.Button","library.i.CheckBox","library.i.Dialog","library.i.Input","library.i.Label","library.i.Link","library.i.Menu","library.i.Text"],"elements":["library.i.MenuItem"],"types":["library.i.ButtonType","library.i.DialogType"],"interfaces":["library.i.IContent"]}}},"sap.fiori":{"registrationIds":["F0042"],"archeType":"fancycomponent"}}' + "library/i/manifest.json":'{"_version":"1.21.0","sap.app":{"id":"library.i","type":"library","embeds":[],"i18n":{"bundleUrl":"i18nf/custommessagebundle.properties","supportedLocales":[""],"fallbackLocale":""},"applicationVersion":{"version":"1.0.0"},"title":"{{title}}","description":"{{description}}","ach":"NOT-ME","resources":"resources.json","offline":false,"openSourceComponents":[{"name":"D3.js","packagedWithMySelf":false},{"name":"Hammer.js","packagedWithMySelf":true,"version":"2.0.4"}]},"sap.ui":{"technology":"UI5","deviceTypes":{"desktop":true,"tablet":true,"phone":true},"supportedThemes":[]},"sap.ui5":{"dependencies":{"minUI5Version":"1.0","libs":{"sap.ui.core":{"minVersion":"1.0.0"},"library.d":{"lazy":true}}},"contentDensities":{"cozy":true,"compact":false},"library":{"i18n":false,"content":{"controls":["library.i.Button","library.i.CheckBox","library.i.Dialog","library.i.Input","library.i.Label","library.i.Link","library.i.Menu","library.i.Text"],"elements":["library.i.MenuItem"],"types":["library.i.ButtonType","library.i.DialogType"],"interfaces":["library.i.IContent"]}}},"sap.fiori":{"registrationIds":["F0042"],"archeType":"fancycomponent"}}' }); //# sourceMappingURL=library-preload.js.map diff --git a/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/manifest.json b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/manifest.json index b10bc0610..0179cfc90 100644 --- a/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/manifest.json +++ b/test/expected/build/library.i/bundle-library.h-build-manifest/resources/library/i/manifest.json @@ -4,7 +4,13 @@ "id": "library.i", "type": "library", "embeds": [], - "i18n": "(i18nPathRelativeToLibrary)", + "i18n": { + "bundleUrl": "i18nf/custommessagebundle.properties", + "supportedLocales": [ + "" + ], + "fallbackLocale": "" + }, "applicationVersion": { "version": "1.0.0" }, diff --git a/test/expected/build/library.i/bundle-library.h/resources/library/i/.library b/test/expected/build/library.i/bundle-library.h/resources/library/i/.library index 4ef9fffe7..acfb88eed 100644 --- a/test/expected/build/library.i/bundle-library.h/resources/library/i/.library +++ b/test/expected/build/library.i/bundle-library.h/resources/library/i/.library @@ -21,7 +21,7 @@ - (i18nPathRelativeToLibrary) + i18nf/custommessagebundle.properties false sap_belize diff --git a/test/expected/build/library.i/bundle-library.h/resources/library/i/i18nf/custommessagebundle.properties b/test/expected/build/library.i/bundle-library.h/resources/library/i/i18nf/custommessagebundle.properties new file mode 100644 index 000000000..dbb825dab --- /dev/null +++ b/test/expected/build/library.i/bundle-library.h/resources/library/i/i18nf/custommessagebundle.properties @@ -0,0 +1 @@ +mytext=Hello \ No newline at end of file diff --git a/test/expected/build/library.i/bundle-library.h/resources/library/i/manifest.json b/test/expected/build/library.i/bundle-library.h/resources/library/i/manifest.json index b10bc0610..0179cfc90 100644 --- a/test/expected/build/library.i/bundle-library.h/resources/library/i/manifest.json +++ b/test/expected/build/library.i/bundle-library.h/resources/library/i/manifest.json @@ -4,7 +4,13 @@ "id": "library.i", "type": "library", "embeds": [], - "i18n": "(i18nPathRelativeToLibrary)", + "i18n": { + "bundleUrl": "i18nf/custommessagebundle.properties", + "supportedLocales": [ + "" + ], + "fallbackLocale": "" + }, "applicationVersion": { "version": "1.0.0" }, diff --git a/test/expected/build/library.i/dest/resources/library/i/.library b/test/expected/build/library.i/dest/resources/library/i/.library index 4ef9fffe7..acfb88eed 100644 --- a/test/expected/build/library.i/dest/resources/library/i/.library +++ b/test/expected/build/library.i/dest/resources/library/i/.library @@ -21,7 +21,7 @@ - (i18nPathRelativeToLibrary) + i18nf/custommessagebundle.properties false sap_belize diff --git a/test/expected/build/library.i/dest/resources/library/i/i18nf/custommessagebundle.properties b/test/expected/build/library.i/dest/resources/library/i/i18nf/custommessagebundle.properties new file mode 100644 index 000000000..dbb825dab --- /dev/null +++ b/test/expected/build/library.i/dest/resources/library/i/i18nf/custommessagebundle.properties @@ -0,0 +1 @@ +mytext=Hello \ No newline at end of file diff --git a/test/expected/build/library.i/dest/resources/library/i/manifest.json b/test/expected/build/library.i/dest/resources/library/i/manifest.json index 77c819c00..7a3ad6ed7 100644 --- a/test/expected/build/library.i/dest/resources/library/i/manifest.json +++ b/test/expected/build/library.i/dest/resources/library/i/manifest.json @@ -4,7 +4,13 @@ "id": "library.i", "type": "library", "embeds": [], - "i18n": "(i18nPathRelativeToLibrary)", + "i18n": { + "bundleUrl": "i18nf/custommessagebundle.properties", + "supportedLocales": [ + "" + ], + "fallbackLocale": "" + }, "applicationVersion": { "version": "1.0.0" }, diff --git a/test/fixtures/library.i/main/src/library/i/.library b/test/fixtures/library.i/main/src/library/i/.library index 8c8c09d1b..e035afe77 100644 --- a/test/fixtures/library.i/main/src/library/i/.library +++ b/test/fixtures/library.i/main/src/library/i/.library @@ -21,7 +21,7 @@ - (i18nPathRelativeToLibrary) + i18nf/custommessagebundle.properties false sap_belize diff --git a/test/fixtures/library.i/main/src/library/i/i18nf/custommessagebundle.properties b/test/fixtures/library.i/main/src/library/i/i18nf/custommessagebundle.properties new file mode 100644 index 000000000..dbb825dab --- /dev/null +++ b/test/fixtures/library.i/main/src/library/i/i18nf/custommessagebundle.properties @@ -0,0 +1 @@ +mytext=Hello \ No newline at end of file diff --git a/test/lib/tasks/generateLibraryManifest.js b/test/lib/tasks/generateLibraryManifest.js index 2df2cab1f..a4a830334 100644 --- a/test/lib/tasks/generateLibraryManifest.js +++ b/test/lib/tasks/generateLibraryManifest.js @@ -145,7 +145,8 @@ test("integration: Library with i18n bundle file (messagebundle.properties)", as library: { i18n: { bundleUrl: "messagebundle.properties", - supportedLocales: [""] + supportedLocales: [""], + fallbackLocale: "" } } }, @@ -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: ` + + + + test.lib + SAP SE + + 2.0.0 + + Test Lib + + + + + + true + + + + + + + `, + 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: ` + + + + test.lib + SAP SE + + 2.0.0 + + Test Lib + + + + + + true + + + + + + + `, + 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" } } }, @@ -345,7 +493,8 @@ test("integration: Library with i18n=foo.properties declared in .library", async library: { i18n: { bundleUrl: "foo.properties", - supportedLocales: [""] + supportedLocales: [""], + fallbackLocale: "" } } },