-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: seo #6860
i18n: seo #6860
Changes from 11 commits
31d658b
8c79982
c8b9f58
42d8dda
60fc6b9
b06fd1f
8306ee7
2c8eea0
ffa4e7c
0570900
f5b7751
7f47810
5b77efe
3292058
b839a63
0f23dee
cf3ed80
feea7c3
93a99bf
7b3fcb5
aa9bb0b
62564d5
6dfbd5c
18a75ee
324db81
5926722
10cafea
7294f93
edea4fb
b122256
2d36b31
4b692fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,31 @@ const LinkHeader = require('http-link-header'); | |||||
const URL = require('../../lib/url-shim'); | ||||||
const MainResource = require('../../computed/main-resource.js'); | ||||||
const LINK_HEADER = 'link'; | ||||||
const i18n = require('../../lib/i18n/i18n.js'); | ||||||
|
||||||
const UIStrings = { | ||||||
/** Title of a Lighthouse audit that provides detail on a page's rel=canonical link. This descriptive title is shown to users when the rel=canonical link is valid. */ | ||||||
title: 'Document has a valid `rel=canonical`', | ||||||
/** Title of a Lighthouse audit that provides detail on a page's rel=canonical link. This imperative title is shown to users when the rel=canonical link is invalid and should be fixed. */ | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
failureTitle: 'Document does not have a valid `rel=canonical`', | ||||||
/** Description of a Lighthouse audit that tells the user *why* they need to have a valid rel=canonical link. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||||||
description: 'Canonical links suggest which URL to show in search results. ' + | ||||||
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/canonical).', | ||||||
/** [ICU Syntax] Explanatory message stating that there was a failure in an audit caused by multiple URLs conflicting with each other. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
explanationConflict: 'Multiple conflicting URLs ({urlList})', | ||||||
/** [ICU Syntax] Explanatory message stating that there was a failure in an audit caused by a URL being invalid. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
explanationInvalid: 'Invalid URL ({url})', | ||||||
/** [ICU Syntax] Explanatory message stating that there was a failure in an audit caused by a URL being relative instead of absolute. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
explanationRelative: 'Relative URL ({url})', | ||||||
/** [ICU Syntax] Explanatory message stating that there was a failure in an audit caused by a URL pointing to a different hreflang than the current context. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
explanationPointsElsewhere: 'Points to another hreflang location ({href})', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is still a URL, so may be good to use the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this should still always be a url. Good point! |
||||||
/** [ICU Syntax] Explanatory message stating that there was a failure in an audit caused by a URL pointing to a different domain. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
explanationDifferentDomain: 'Points to a different domain ({url})', | ||||||
/** Explanatory message stating that the page's canonical URL was pointing to a root of the same origin which is a common mistake. The canonical URL should point a different page with the same content whose URL is preferred, not a parent or root page. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is confusing but my brain is tired from reviewing this PR now :) "root of the same origin" is the main thing that needs to be defined here (root directory and something about the origin...not sure if we have an existing origin we can reuse) |
||||||
explanationRoot: 'Points to a root of the same origin', | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
}; | ||||||
|
||||||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||||||
|
||||||
/** | ||||||
* @param {string} headerValue | ||||||
|
@@ -62,10 +87,9 @@ class Canonical extends Audit { | |||||
static get meta() { | ||||||
return { | ||||||
id: 'canonical', | ||||||
title: 'Document has a valid `rel=canonical`', | ||||||
failureTitle: 'Document does not have a valid `rel=canonical`', | ||||||
description: 'Canonical links suggest which URL to show in search results. ' + | ||||||
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/canonical).', | ||||||
title: str_(UIStrings.title), | ||||||
failureTitle: str_(UIStrings.failureTitle), | ||||||
description: str_(UIStrings.description), | ||||||
requiredArtifacts: ['Canonical', 'Hreflang', 'URL'], | ||||||
}; | ||||||
} | ||||||
|
@@ -118,7 +142,7 @@ class Canonical extends Audit { | |||||
if (canonicals.length > 1) { | ||||||
return { | ||||||
rawValue: false, | ||||||
explanation: `Multiple conflicting URLs (${canonicals.join(', ')})`, | ||||||
explanation: str_(UIStrings.explanationConflict, {urlList: canonicals.join(', ')}), | ||||||
}; | ||||||
} | ||||||
|
||||||
|
@@ -127,14 +151,14 @@ class Canonical extends Audit { | |||||
if (!isValidRelativeOrAbsoluteURL(canonical)) { | ||||||
return { | ||||||
rawValue: false, | ||||||
explanation: `Invalid URL (${canonical})`, | ||||||
explanation: str_(UIStrings.explanationInvalid, {url: canonical}), | ||||||
}; | ||||||
} | ||||||
|
||||||
if (!URL.isValid(canonical)) { | ||||||
return { | ||||||
rawValue: false, | ||||||
explanation: `Relative URL (${canonical})`, | ||||||
explanation: str_(UIStrings.explanationRelative, {url: canonical}), | ||||||
}; | ||||||
} | ||||||
|
||||||
|
@@ -145,7 +169,7 @@ class Canonical extends Audit { | |||||
baseURL.href !== canonicalURL.href) { | ||||||
return { | ||||||
rawValue: false, | ||||||
explanation: `Points to another hreflang location (${baseURL.href})`, | ||||||
explanation: str_(UIStrings.explanationPointsElsewhere, {href: baseURL.href}), | ||||||
}; | ||||||
} | ||||||
|
||||||
|
@@ -154,7 +178,7 @@ class Canonical extends Audit { | |||||
if (getPrimaryDomain(canonicalURL) !== getPrimaryDomain(baseURL)) { | ||||||
return { | ||||||
rawValue: false, | ||||||
explanation: `Points to a different domain (${canonicalURL})`, | ||||||
explanation: str_(UIStrings.explanationDifferentDomain, {url: canonicalURL}), | ||||||
}; | ||||||
} | ||||||
|
||||||
|
@@ -163,7 +187,7 @@ class Canonical extends Audit { | |||||
canonicalURL.pathname === '/' && baseURL.pathname !== '/') { | ||||||
return { | ||||||
rawValue: false, | ||||||
explanation: 'Points to a root of the same origin', | ||||||
explanation: str_(UIStrings.explanationRoot), | ||||||
}; | ||||||
} | ||||||
|
||||||
|
@@ -175,3 +199,4 @@ class Canonical extends Audit { | |||||
} | ||||||
|
||||||
module.exports = Canonical; | ||||||
module.exports.UIStrings = UIStrings; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -14,14 +14,22 @@ const ViewportAudit = require('../viewport'); | |||||
const MINIMAL_PERCENTAGE_OF_LEGIBLE_TEXT = 60; | ||||||
|
||||||
const UIStrings = { | ||||||
/** Imperative title of a Lighthouse audit that tells the user that they should use font sizes that are easily read by the user. This is displayed in a list of audit titles that Lighthouse generates. */ | ||||||
/** Title of a Lighthouse audit that provides detail on the font sizes used on the page. This descriptive title is shown to users when the fonts used on the page are large enough to be considered legible. */ | ||||||
title: 'Document uses legible font sizes', | ||||||
/** Imperative title of a Lighthouse audit that tells the user that they should use font sizes that are easily read by the user. This imperative title is shown to users when there is a font that is too small to be read by the user. */ | ||||||
/** Title of a Lighthouse audit that provides detail on the font sizes used on the page. This imperative title is shown to users when there is a font that is too small to be read by the user. */ | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
failureTitle: 'Document doesn\'t use legible font sizes', | ||||||
/** Description of a Lighthouse audit that tells the user *why* they need to use a larger font size. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||||||
description: 'Font sizes less than 12px are too small to be legible and require mobile visitors to “pinch to zoom” in order to read. Strive to have >60% of page text ≥12px. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/font-sizes).', | ||||||
/** [ICU Syntax] Label for the audit identifying font sizes that are too small. */ | ||||||
displayValue: '{decimalProportion, number, extendedPercent} legible text', | ||||||
/** Explanatory message stating that there was a failure in an audit caused by a missing page viewport meta tag configuration. */ | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
explanationViewport: 'Text is illegible because there\'s no viewport meta tag optimized ' + | ||||||
'for mobile screens.', | ||||||
/** Explanatory message stating that there was a failure in an audit caused by a certain percentage of the text on the page being too small. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
explanation: '{decimalProportion, number, extendedPercent} of text is too small.', | ||||||
/** Explanatory message stating that there was a failure in an audit caused by a certain percentage of the text on the page being too small, based on a sample size of text that was less than 100% of the text on the page. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
explanationWithDisclaimer: '{decimalProportion, number, extendedPercent} of text is too ' + | ||||||
'small (based on {decimalProportionVisited, number, extendedPercent} sample).', | ||||||
}; | ||||||
|
||||||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||||||
|
@@ -212,8 +220,7 @@ class FontSize extends Audit { | |||||
if (!hasViewportSet) { | ||||||
return { | ||||||
rawValue: false, | ||||||
explanation: | ||||||
'Text is illegible because there\'s no viewport meta tag optimized for mobile screens', | ||||||
explanation: str_(UIStrings.explanationViewport), | ||||||
}; | ||||||
} | ||||||
|
||||||
|
@@ -286,16 +293,20 @@ class FontSize extends Audit { | |||||
|
||||||
let explanation; | ||||||
if (!passed) { | ||||||
const percentageOfFailingText = parseFloat((100 - percentageOfPassingText).toFixed(2)); | ||||||
let disclaimer = ''; | ||||||
const percentageOfFailingText = parseFloat((100 - percentageOfPassingText).toFixed(2)) / 100; | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
// if we were unable to visit all text nodes we should disclose that information | ||||||
if (visitedTextLength < totalTextLength) { | ||||||
const percentageOfVisitedText = visitedTextLength / totalTextLength * 100; | ||||||
disclaimer = ` (based on ${percentageOfVisitedText.toFixed()}% sample)`; | ||||||
const percentageOfVisitedText = (visitedTextLength / totalTextLength).toFixed(2); | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
explanation = str_(UIStrings.explanationWithDisclaimer, | ||||||
{ | ||||||
decimalProportion: percentageOfFailingText, | ||||||
decimalProportionVisited: percentageOfVisitedText, | ||||||
}); | ||||||
} else { | ||||||
explanation = str_(UIStrings.explanation, | ||||||
{decimalProportion: percentageOfFailingText}); | ||||||
} | ||||||
|
||||||
explanation = `${percentageOfFailingText}% of text is too small${disclaimer}.`; | ||||||
} | ||||||
|
||||||
return { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,6 +11,20 @@ const MainResource = require('../../computed/main-resource.js'); | |||||
const VALID_LANGS = importValidLangs(); | ||||||
const LINK_HEADER = 'link'; | ||||||
const NO_LANGUAGE = 'x-default'; | ||||||
const i18n = require('../../lib/i18n/i18n.js'); | ||||||
|
||||||
const UIStrings = { | ||||||
/** Title of a Lighthouse audit that provides detail on the `hreflang` element on a page. This descriptive title is shown when the `hreflang` element is configured correctly. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
title: 'Document has a valid `hreflang`', | ||||||
/** Title of a Lighthouse audit that provides detail on the `hreflang` element on a page. This imperative title is shown when the `hreflang` element is not valid and needs to be fixed. */ | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
failureTitle: 'Document doesn\'t have a valid `hreflang`', | ||||||
/** Description of a Lighthouse audit that tells the user *why* they need to have an hreflang link on their page. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
description: 'hreflang links tell search engines what version of a page they should ' + | ||||||
'list in search results for a given language or region. [Learn more]' + | ||||||
'(https://developers.google.com/web/tools/lighthouse/audits/hreflang).', | ||||||
}; | ||||||
|
||||||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||||||
|
||||||
/** | ||||||
* Import list of valid languages from axe core without including whole axe-core package | ||||||
|
@@ -65,11 +79,9 @@ class Hreflang extends Audit { | |||||
static get meta() { | ||||||
return { | ||||||
id: 'hreflang', | ||||||
title: 'Document has a valid `hreflang`', | ||||||
failureTitle: 'Document doesn\'t have a valid `hreflang`', | ||||||
description: 'hreflang links tell search engines what version of a page they should ' + | ||||||
'list in search results for a given language or region. [Learn more]' + | ||||||
'(https://developers.google.com/web/tools/lighthouse/audits/hreflang).', | ||||||
title: str_(UIStrings.title), | ||||||
failureTitle: str_(UIStrings.failureTitle), | ||||||
description: str_(UIStrings.description), | ||||||
requiredArtifacts: ['Hreflang', 'URL'], | ||||||
}; | ||||||
} | ||||||
|
@@ -119,3 +131,4 @@ class Hreflang extends Audit { | |||||
} | ||||||
|
||||||
module.exports = Hreflang; | ||||||
module.exports.UIStrings = UIStrings; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,6 +15,20 @@ const BLOCKLIST = new Set([ | |||||
]); | ||||||
const ROBOTS_HEADER = 'x-robots-tag'; | ||||||
const UNAVAILABLE_AFTER = 'unavailable_after'; | ||||||
const i18n = require('../../lib/i18n/i18n.js'); | ||||||
|
||||||
const UIStrings = { | ||||||
/** Title of a Lighthouse audit that provides detail on the blocking status of their page in regards to search-engine index crawling. This descriptive title is shown when the page is not blocked from indexing and can be crawled. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
title: 'Page isn’t blocked from indexing', | ||||||
/** Title of a Lighthouse audit that provides detail on the blocking status of their page in regards to search-engine index crawling. This imperative title is shown when the page has been configured to block indexing and therefore cannot be indexed by search engines. */ | ||||||
failureTitle: 'Page is blocked from indexing', | ||||||
/** Description of a Lighthouse audit that tells the user *why* they need to allow crawling on their page. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
description: 'Search engines are unable to include your pages in search results ' + | ||||||
'if they don\'t have permission to crawl them. [Learn ' + | ||||||
'more](https://developers.google.com/web/tools/lighthouse/audits/indexing).', | ||||||
}; | ||||||
|
||||||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||||||
|
||||||
/** | ||||||
* Checks if given directive is a valid unavailable_after directive with a date in the past | ||||||
|
@@ -64,11 +78,9 @@ class IsCrawlable extends Audit { | |||||
static get meta() { | ||||||
return { | ||||||
id: 'is-crawlable', | ||||||
title: 'Page isn’t blocked from indexing', | ||||||
failureTitle: 'Page is blocked from indexing', | ||||||
description: 'Search engines are unable to include your pages in search results ' + | ||||||
'if they don\'t have permission to crawl them. [Learn ' + | ||||||
'more](https://developers.google.com/web/tools/lighthouse/audits/indexing).', | ||||||
title: str_(UIStrings.title), | ||||||
failureTitle: str_(UIStrings.failureTitle), | ||||||
description: str_(UIStrings.description), | ||||||
requiredArtifacts: ['MetaElements', 'RobotsTxt', 'URL'], | ||||||
}; | ||||||
} | ||||||
|
@@ -134,3 +146,4 @@ class IsCrawlable extends Audit { | |||||
} | ||||||
|
||||||
module.exports = IsCrawlable; | ||||||
module.exports.UIStrings = UIStrings; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,6 +18,24 @@ const BLOCKLIST = new Set([ | |||||
'more', | ||||||
'learn more', | ||||||
]); | ||||||
const i18n = require('../../lib/i18n/i18n.js'); | ||||||
|
||||||
const UIStrings = { | ||||||
/** Title of a Lighthouse audit that provides detail on the text descriptions used for links on the page. This descriptive title is shown when all links on the page have sufficient textual descriptions. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
title: 'Links have descriptive text', | ||||||
/** Title of a Lighthouse audit that provides detail on the text descriptions used for links on the page. This imperative title is shown when one or more links on the page do not have enough text describing them to be considered valid when being crawled by a search engine. */ | ||||||
exterkamp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
failureTitle: 'Links do not have descriptive text', | ||||||
/** Description of a Lighthouse audit that tells the user *why* they need to have descriptive text on the links in their page. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||||||
description: 'Descriptive link text helps search engines understand your content. ' + | ||||||
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/descriptive-link-text).', | ||||||
/** [ICU Syntax] Label for the audit identifying the number of links found. */ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
displayValue: `{itemCount, plural, | ||||||
=1 {1 link found} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are there any docs explaining how this format works There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
other {# links found} | ||||||
}`, | ||||||
}; | ||||||
|
||||||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||||||
|
||||||
class LinkText extends Audit { | ||||||
/** | ||||||
|
@@ -26,10 +44,9 @@ class LinkText extends Audit { | |||||
static get meta() { | ||||||
return { | ||||||
id: 'link-text', | ||||||
title: 'Links have descriptive text', | ||||||
failureTitle: 'Links do not have descriptive text', | ||||||
description: 'Descriptive link text helps search engines understand your content. ' + | ||||||
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/descriptive-link-text).', | ||||||
title: str_(UIStrings.title), | ||||||
failureTitle: str_(UIStrings.failureTitle), | ||||||
description: str_(UIStrings.description), | ||||||
requiredArtifacts: ['URL', 'CrawlableLinks'], | ||||||
}; | ||||||
} | ||||||
|
@@ -68,8 +85,7 @@ class LinkText extends Audit { | |||||
let displayValue; | ||||||
|
||||||
if (failingLinks.length) { | ||||||
displayValue = failingLinks.length > 1 ? | ||||||
`${failingLinks.length} links found` : '1 link found'; | ||||||
displayValue = str_(UIStrings.displayValue, {itemCount: failingLinks.length}); | ||||||
} | ||||||
|
||||||
return { | ||||||
|
@@ -81,3 +97,4 @@ class LinkText extends Audit { | |||||
} | ||||||
|
||||||
module.exports = LinkText; | ||||||
module.exports.UIStrings = UIStrings; |
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.