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

i18n: align type names with docs #9461

Merged
merged 1 commit into from
Jul 29, 2019
Merged

i18n: align type names with docs #9461

merged 1 commit into from
Jul 29, 2019

Conversation

brendankenny
Copy link
Member

Follow up to #9114

if (artifacts.AppCacheManifest !== null) {
return {
score: 0,
displayValue: str_(UIStrings.displayValue, {AppCacheManifest: artifacts.AppCacheManifest}),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsc couldn't tell this would never be null

@@ -178,7 +178,7 @@ class Canonical extends Audit {
if (!URL.rootDomainsMatch(canonicalURL, baseURL)) {
return {
score: 0,
explanation: str_(UIStrings.explanationDifferentDomain, {url: canonicalURL}),
explanation: str_(UIStrings.explanationDifferentDomain, {url: canonicalURL.href}),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsc couldn't tell this would have been toString()ed

* @property {string} content the string that will be substituted into a message
* @property {string} [example] an example (to assist translators) of what the content may be in the final string
*/

/**
* @typedef LhlMessage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than having the LHL messages be types of CTC messages (since all the CTC message properties were optional except message), makes sense to split the two

* @property {string} [description] a string used by translators to give context to the message
* @property {string} [meaning] an arbitrary strings used by translators to differentiate messages that have the same message
* @property {Record<string, ICUPlaceholderDefn>} [placeholders] a set of values that are to be replaced in a message
* @property {string} description a string used by translators to give context to the message
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we require this so should be required

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -50,7 +50,8 @@ function swapLocale(lhr, requestedLocale) {

const locale = i18n.lookupLocale(requestedLocale);
const {icuMessagePaths} = lhr.i18n;
const missingIcuMessageIds = /** @type {string[]} */([]);
/** @type {string[]} */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this have any practical effect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this have any practical effect?

no, just a cast is overkill and may cause a double take :)

@@ -103,37 +105,38 @@ function computeDescription(ast, property, value, startRange) {
*
* @param {string} message
* @param {Record<string, string>} examples
* @return {ICUMessageDefn}
* @return {Pick<CtcMessage, 'message'|'placeholders'>}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return {Pick<CtcMessage, 'message'|'placeholders'>}
* @return {IncrementalCtc}

right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right?

yeah, takes some changes but probably for the best

lighthouse-core/scripts/i18n/collect-strings.js Outdated Show resolved Hide resolved
@@ -430,7 +435,7 @@ function collectAllStringsInDir(dir, strings = {}) {

const messageKey = `${relativePath} | ${key}`;

/** @type {ICUMessageDefn} */
/** @type {CtcMessage} */
const icuDefn = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here?

done

Copy link
Member

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this. Makes it much more clear what each object is at each point 😍

@@ -172,14 +172,14 @@ describe('Convert Message to Placeholder', () => {
it('passthroughs a basic message unchanged', () => {
const message = 'Hello World.';
const res = collect.convertMessageToPlaceholders(message, undefined);
expect(res).toEqual({message, placeholders: undefined});
expect(res).toEqual({message, placeholders: {}});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arg. This is less strict again 😦 Now there isn't a great check for regressions unless someone looks at the .ctc.json files after generation. Not a showstopper, but I liked that this was caught in the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arg. This is less strict again 😦 Now there isn't a great check for regressions unless someone looks at the .ctc.json files after generation. Not a showstopper, but I liked that this was caught in the test.

yeah, we can play with a way to make it caught, but this was part of my thinking on if we should check in en-US.ctc.json after all...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants