Providing i18n translations for (custom) audits
See original GitHub issueInject Translations for custom audits
There is currently no information in the docs on how to add I18N translations for locales for a custom audit.
I have a custom audit like the one below and want to provide a translation for a given locale (let’s say ‘fr’). How to proceed? How to inject or reference a json file with my custom translations for several locales?
'use strict';
const Audit = require('lighthouse').Audit;
const i18n = require('lighthouse/lighthouse-core/lib/i18n/i18n.js');
const UIStrings = {
title: 'A crazy audit',
failureTitle: 'Audit failed massively',
description: 'This is a test. This is not real. ',
};
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
class MyCustomAudit extends Audit {
static get meta() {
return {
id: 'my-custom-audit',
title: str_(UIStrings.title),
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
};
}
static audit(artifacts) {
[...]
}
}
module.exports = MyCustomAudit;
There also sees to be no way to provide another JSON files as extension to the existing locale files in lighthouse-core to overwrite an existing translation or to provide a missing translation during runtime without touching core files.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Custom Translations | ThingsBoard Professional Edition
ThingsBoard Custom Translations feature allows you to upload alternative to existing language translations and extend the translation to specific GUI ...
Read more >Website Localization Audit Offer
Definitive guide to localization (38 pages of value!) Translation checklist; Preparing your website for localization questionnaire; Manufacturing guide to ...
Read more >Internationalization Support for Additional Languages
ServiceNow provides support for localizing the application to be translated to languages which are not available with the localization ...
Read more >Add a custom Localization Framework setting to enable ...
Navigate to All > Localization Framework > Settings. · In the Setting list, select New. · Enter a name for the setting. ·...
Read more >Web UI Translations | Nuxeo Documentation
Learn how translations are managed technically in Nuxeo Web UI. ... which provides the i18n method to dynamically load labels according to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The reason for us to override core translations is that some of the translations are too technical for our audience of the reports, so we want to change them completely (during runtime), in other cases we simply wanted to add a sentence or two.
For the time being we have built the functionality with a handful of new lines of code to
i18n.js
as well as including they18n
package and preserve the changes withpatch-package
to enable both requested features for us.If translations for custom audits become a core feature though, this would be appreciated.
Update: We introduced a
i18n.registerLocaleData()
method in https://github.com/GoogleChrome/lighthouse/pull/9638 We didn’t intend for it to be used outside of the Lighthouse internals, but it certainly could be.We still don’t offer a first-class i18n story for custom audits.