From a2f02472d98de24e41d54c8756e366ad62f2d2ee Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Thu, 21 Nov 2019 09:29:00 -0700 Subject: [PATCH] fix(build): add lang query parameter to helpUrl when builing with a locale (#1909) * fix(build); add lang query parameter to helpUrl when builing with a locale * add test * fix test --- build/configure.js | 1 + lib/core/base/audit.js | 1 + test/core/public/load.js | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/build/configure.js b/build/configure.js index fe3da8536e..a0e1fe09d5 100644 --- a/build/configure.js +++ b/build/configure.js @@ -276,6 +276,7 @@ function buildRules(grunt, options, commons, callback) { auto: replaceFunctions( JSON.stringify( { + lang: options.locale || 'en', data: metadata, rules: rules, checks: checks, diff --git a/lib/core/base/audit.js b/lib/core/base/audit.js index 9a27056c20..e1d973998a 100644 --- a/lib/core/base/audit.js +++ b/lib/core/base/audit.js @@ -308,6 +308,7 @@ Audit.prototype._init = function() { axe.commons = commons = audit.commons; + this.lang = audit.lang || 'en'; this.reporter = audit.reporter; this.commands = {}; this.rules = []; diff --git a/test/core/public/load.js b/test/core/public/load.js index 50deb3af8c..611e3a3349 100644 --- a/test/core/public/load.js +++ b/test/core/public/load.js @@ -49,6 +49,13 @@ describe('axe._load', function() { assert.equal(axe.commons, 'foo'); }); + it('should load with a lang', function() { + axe._load({ + lang: 'ja' + }); + assert.equal(axe._audit.lang, 'ja'); + }); + describe('respondable subscriber', function() { it('should add a respondable subscriber', function() { var mockAudit = {