-
Notifications
You must be signed in to change notification settings - Fork 23
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
[FEATURE] manifestCreator: enrich manifest with supportedLocales in i18n (for libraries) #547
Conversation
ba9f72b
to
745509b
Compare
t.is(verboseLogStub.getCall(1).args[1], "/resources/sap/apf"); | ||
}); | ||
|
||
test.serial("manifest creation for sap/ui/core", async (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed by accident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restored with:
535668a
lib/processors/manifestCreator.js
Outdated
} else { | ||
return false; | ||
} | ||
} | ||
// i18n can be an empty string therefore check for not being null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for an empty string createI18nSection
returns false
anyways. Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tackled with: 8eaf458
lib/processors/manifestCreator.js
Outdated
* <code>null</code> if given i18n String is <code>null</code> | ||
*/ | ||
function createI18nSection(i18n, i18nToSupportedLocales) { | ||
if (!i18n) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this handles the empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tackled with: 8eaf458
lib/processors/manifestCreator.js
Outdated
supportedLocales.add(""); | ||
} | ||
const i18nPatternStr = i18n.substring(0, i18n.length - ".properties".length); | ||
const i18nRegexp = new RegExp(i18nPatternStr + "_([^.]+)\\.properties$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does i18nPatternStr
need to be encoded for RegExp or can we be sure that it doesn't contain special characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tackled with: f649422
lib/processors/manifestCreator.js
Outdated
i18nToSupportedLocales.set(i18n, supportedLocales); | ||
} | ||
|
||
const supportedLocalesArray = [...supportedLocales]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is fine to convert the Set to an Array I think Array.from(supportedLocales)
would be easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I like the spread operator more, but that's a matter of taste.
With both ways, I anyhow struggle with the details of iteration (whether it iterates entries - like for Object.entries or Map's default iterator - or only values).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed with: c90b9a4
ff9521e
to
53986f9
Compare
With app descriptor v22 (1.21.0) the i18n sections in the manifest are objects with: * bundleUrl * supportedLocales
adjusted line length
fixed tests after rebase
restored test
Improve i18n language extraction code by avoiding regexp
Add test and comments
Adjust test code
avoid duplicate check for null because createI18nSection() also performs an existence check
changed to Array.from instead of spread operator.
and is reflected as such in the manifest.json "i18n": ""
b651ad1
to
fdec47a
Compare
Add "return" after "reject() call", because a promise should either reject or resovle.
With app descriptor v22 (1.21.0) the i18n sections in the manifest can be an object
with:
This change reads the provided properties files and automatically creates the supportedLocales
array based on this information.
e.g.
files:
snippet in manifest.json