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

feat: deprecate the use doT.js for messages #1938

Merged
merged 11 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
straker committed Dec 12, 2019
commit d541b478d4e6fa7af9f48983296360446a416ceb
129 changes: 95 additions & 34 deletions locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,21 @@
},
"aria-allowed-attr": {
"pass": "ARIA属性が定義されたロールに対して正しく使用されています",
"fail": "ARIA属性は許可されていません:{{~it.data:value}} {{=value}}{{~}}"
"fail": {
"singular": "ARIA attribute is not allowed: ${data.values}",
"plural": "ARIA attributes are not allowed: ${data.values}"
}
},
"aria-allowed-role": {
"pass": "ARIAロールは指定された要素に対して許可されています",
"fail": "ARIAロールは指定された要素に許可されていません",
"incomplete": "ARIAロールはこの要素に許可されていないため、要素が表示されたときはARIAロールを削除する必要があります"
"fail": {
"singular": "ARIA role ${data.values} is not allowed for given element",
"plural": "ARIA roles ${data.values} are not allowed for given element"
},
"incomplete": {
"singular": "ARIA role ${data.values} must be removed when the element is made visible, as it is not allowed for the element",
"plural": "ARIA roles ${data.values} must be removed when the element is made visible, as they are not allowed for the element"
}
},
"aria-hidden-body": {
"pass": "ドキュメント本体にaria-hidden属性は存在していません",
Expand All @@ -367,7 +376,10 @@
},
"aria-errormessage": {
"pass": "サポートされているaria-errormessageの技術を使用しています",
"fail": "aria-errormessageの値{{~it.data:value}} `{{=value}}{{~}}`はメッセージを通知する方法を使用しなければなりません (例えば、aria-live、aria-describedby、role=alert等)"
"fail": {
"singular": "aria-errormessage value `${data.values}` must use a technique to announce the message (e.g., aria-live, aria-describedby, role=alert, etc.)",
"plural": "aria-errormessage values `${data.values}` must use a technique to announce the message (e.g., aria-live, aria-describedby, role=alert, etc.)"
}
},
"has-widget-role": {
"pass": "要素にはwidgetロールが存在しています",
Expand All @@ -387,16 +399,28 @@
},
"aria-required-attr": {
"pass": "すべての必須のARIA属性が存在しています",
"fail": "必須のARIA属性が提供されていません:{{~it.data:value}} {{=value}}{{~}}"
"fail": {
"singular": "Required ARIA attribute not present: ${data.values}",
"plural": "Required ARIA attributes not present: ${data.values}"
}
},
"aria-required-children": {
"pass": "必須のARIA子ロールが存在しています",
"fail": "必須のARIA子ロールが提供されていません:{{~it.data:value}} {{=value}}{{~}}",
"incomplete": "ARIAの子ロールが追加されることを求めています:{{~it.data:value}} {{=value}}{{~}}"
"fail": {
"singular": "Required ARIA child role not present: ${data.values}",
"plural": "Required ARIA children role not present: ${data.values}"
},
"incomplete": {
"singular": "Expecting ARIA child role to be added: ${data.values}",
"plural": "Expecting ARIA children role to be added: ${data.values}"
}
},
"aria-required-parent": {
"pass": "必須のARIA親ロールが存在しています",
"fail": "必須のARIA親ロールが提供されていません:{{~it.data:value}} {{=value}}{{~}}"
"fail": {
"singular": "Required ARIA parent role not present: ${data.values}",
"plural": "Required ARIA parents role not present: ${data.values}"
}
},
"aria-unsupported-attr": {
"pass": "ARIA属性はサポートされています",
Expand All @@ -408,12 +432,21 @@
},
"aria-valid-attr-value": {
"pass": "ARIA属性値が有効です",
"fail": "無効なARIA属性値です:{{~it.data:value}} {{=value}}{{~}}",
"incomplete": "ページにARIA属性の要素IDが存在しません:{{~it.data:value}} {{=value}}{{~}}"
"fail": {
"singular": "Invalid ARIA attribute value: ${data.values}",
"plural": "Invalid ARIA attribute values: ${data.values}"
},
"incomplete": {
"singular": "ARIA attribute element ID does not exist on the page: ${data.values}",
"plural": "ARIA attributes element ID does not exist on the page: ${data.values}"
}
},
"aria-valid-attr": {
"pass": "ARIA属性名が有効です",
"fail": "無効なARIA属性名です:{{~it.data:value}} {{=value}}{{~}}"
"fail": {
"singular": "Invalid ARIA attribute name: ${data.values}",
"plural": "Invalid ARIA attribute names: ${data.values}"
}
},
"valid-scrollable-semantics": {
"pass": "要素はフォーカス順序に含まれる要素に対して有効なセマンティクスを持ちます",
Expand All @@ -423,29 +456,33 @@
"pass": "要素には{{=it.data.contrastRatio}}の十分なコントラスト比があります",
"fail": "要素のコントラスト比が不十分です {{=it.data.contrastRatio}}(前景色: {{=it.data.fgColor}}、背景色: {{=it.data.bgColor}}、フォントサイズ: {{=it.data.fontSize}}、フォントの太さ: {{=it.data.fontWeight}})。コントラスト比{{=it.data.expectedContrastRatio}}を必要とします",
"incomplete": {
"bgImage": "背景画像のため、要素の背景色を判定できません",
"bgGradient": "背景グラデーションのため、要素の背景色を判定できません",
"imgNode": "画像ノードが含まれるため、要素の背景色を判定できません",
"bgOverlap": "他の要素と重なっているため、要素の背景色を判定できません",
"fgAlpha": "アルファ透明度により、要素の前景色を判定できません",
"elmPartiallyObscured": "他の要素により部分的に不明瞭なため、要素の背景色を判定できません",
"elmPartiallyObscuring": "他の要素と部分的に重なっているため、要素の背景色を判定できません",
"outsideViewport": "ビューポートの外にあるため、要素の背景色を判定できません",
"equalRatio": "要素のコントラスト比が背景と1:1です",
"shortTextContent": "実際のテキストコンテンツであるかを判断するには要素のコンテンツが短すぎます",
"default": "コントラスト比を判定できません"
"default": "コントラスト比を判定できません",
"missingData": {
"bgImage": "Element's background color could not be determined due to a background image",
"bgGradient": "Element's background color could not be determined due to a background gradient",
"imgNode": "Element's background color could not be determined because element contains an image node",
"bgOverlap": "Element's background color could not be determined because it is overlapped by another element",
"fgAlpha": "Element's foreground color could not be determined because of alpha transparency",
"elmPartiallyObscured": "Element's background color could not be determined because it's partially obscured by another element",
"elmPartiallyObscuring": "Element's background color could not be determined because it partially overlaps other elements",
"outsideViewport": "Element's background color could not be determined because it's outside the viewport",
"equalRatio": "Element has a 1:1 contrast ratio with the background",
"shortTextContent": "Element content is too short to determine if it is actual text content"
}
}
},
"link-in-text-block": {
"pass": "リンクは色以外の方法で周囲のテキストと区別できます",
"fail": "リンクは色以外の方法で周囲のテキストと区別させる必要があります",
"incomplete": {
"bgContrast": "要素のコントラスト比を判定できません。明確なホバー/フォーカススタイルを確認します",
"bgImage": "背景画像のため、要素のコントラスト比を判定できません",
"bgGradient": "背景グラデーションのため、要素のコントラスト比を判定できません",
"imgNode": "画像ノードが含まれるため、要素のコントラスト比を判定できません",
"bgOverlap": "要素の重なりにより、要素のコントラスト比を判定できません",
"default": "コントラスト比を判定できません"
"default": "コントラスト比を判定できません",
"missingData": {
"bgContrast": "Element's contrast ratio could not be determined. Check for a distinct hover/focus style",
"bgImage": "Element's contrast ratio could not be determined due to a background image",
"bgGradient": "Element's contrast ratio could not be determined due to a background gradient",
"imgNode": "Element's contrast ratio could not be determined because element contains an image node",
"bgOverlap": "Element's contrast ratio could not be determined because of element overlap"
}
}
},
"autocomplete-appropriate": {
Expand All @@ -458,11 +495,26 @@
},
"fieldset": {
"pass": "フィールドセット内に要素が含まれています",
"fail": "{{var code = it.data && it.data.failureCode;}}{{? code === 'no-legend'}}フィールドセットの最初の子要素としてレジェンドが存在しません{{?? code === 'empty-legend'}}スクリーン・リーダーに認識可能なテキストがレジェンドに存在しません{{?? code === 'mixed-inputs'}}フィールドセットに関連性のない入力欄が含まれています{{?? code === 'no-group-label'}}ARIAグループにaria-labelまたはaria-labelledbyが存在しません{{?? code === 'group-mixed-inputs'}}ARIAグループに関連性のない入力欄が含まれています{{??}}要素を含有するフィールドセットまたはARIAグループがありません{{?}}"
"fail": {
"default": "Element does not have a containing fieldset or ARIA group",
"failureCode": {
"no-legend": "Fieldset does not have a legend as its first child",
"empty-legend": "Legend does not have text that is visible to screen readers",
"mixed-inputs": "Fieldset contains unrelated inputs",
"no-group-label": "ARIA group does not have aria-label or aria-labelledby",
"group-mixed-inputs": "ARIA group contains unrelated inputs"
}
}
},
"group-labelledby": {
"pass": "\"{{=it.data.name}}\" という名前を持つ要素には、共通のラベルおよび一意のラベルがあり、aria-labelledbyを通じて参照されます",
"fail": "{{var code = it.data && it.data.failureCode;}} \"{{=it.data.name}}\" という名前を持つ要素すべてに対してaria-labelledbyを通じて参照される {{? code === 'no-shared-label' }} 共通のラベル {{?? code === 'no-unique-label' }} 一意のラベル {{??}} 共通のラベルおよび一意のラベル両方 {{?}} がありません"
"fail": {
"default": "Elements with the name \"${data.name}\" do not all have both a shared label, and a unique label referenced through aria-labelledby",
"failureCode": {
"no-shared-label": "Elements with the name \"${data.name}\" do not all have a shared label referenced through aria-labelledby",
"no-unique-label": "Elements with the name \"${data.name}\" do not all have a unique label referenced through aria-labelledby"
}
}
},
"accesskeys": {
"pass": "アクセスキー属性値は一意です",
Expand Down Expand Up @@ -574,7 +626,10 @@
},
"listitem": {
"pass": "リスト項目に<ul>、<ol>、またはrole=\"list\"親要素が存在しています",
"fail": "リスト項目に<ul>、<ol>、またはrole=\"list\"親要素が存在していません"
"fail": {
"default": "List item does not have a <ul>, <ol> parent element",
"roleNotValid": "List item does not have a <ul>, <ol> parent element without a role, or a role=\"list\""
}
},
"only-dlitems": {
"pass": "リスト要素に<dt>または<dd>要素内で許可された直接の子要素のみが存在しています",
Expand Down Expand Up @@ -673,7 +728,10 @@
},
"avoid-inline-spacing": {
"pass": "テキストの間隔に影響する '!important' のついたインラインスタイルは指定されていません",
"fail": "ほとんどのブラウザーで上書きすることはサポートされていないため、インラインスタイル {{=it.data.join(', ')}}, から '!important' を削除します"
"fail": {
"singular": "Remove '!important' from inline style ${data.values}, as overriding this is not supported by most browsers",
"plural": "Remove '!important' from inline styles ${data.values}, as overriding this is not supported by most browsers"
}
},
"button-has-visible-text": {
"pass": "要素にスクリーン・リーダーが認識可能な内部テキストが存在しています",
Expand All @@ -685,7 +743,7 @@
},
"exists": {
"pass": "要素は存在していません",
"fail": "要素が存在しています"
"incomplete": "Element exists"
},
"has-alt": {
"pass": "要素にalt属性が存在しています",
Expand All @@ -704,7 +762,10 @@
"fail": "要素にalt属性が存在していない、またはalt属性が空です"
},
"non-empty-if-present": {
"pass": "要素 {{?it.data}}に空ではないvalue属性が存在しています{{??}}value属性が存在していません{{?}}",
"pass": {
"default": "Element does not have a value attribute",
"has-label": "Element has a non-empty value attribute"
},
"fail": "要素にvalue属性が存在し、value属性が空です"
},
"non-empty-title": {
Expand Down
64 changes: 52 additions & 12 deletions test/core/public/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ describe('axe.configure', function() {
var audit = axe._audit;
var localeData = audit.data;

assert.equal(localeData.rules.greeting.help(), 'hi');
assert.equal(localeData.rules.greeting.description(), 'hello');
assert.equal(localeData.checks.banana.messages.pass(), 'pizza');
assert.equal(localeData.checks.banana.messages.fail(), 'icecream');
assert.equal(localeData.rules.greeting.help, 'hi');
assert.equal(localeData.rules.greeting.description, 'hello');
assert.equal(localeData.checks.banana.messages.pass, 'pizza');
assert.equal(localeData.checks.banana.messages.fail, 'icecream');
assert.deepEqual(localeData.checks.banana.messages.incomplete, {
foo: 'meat',
bar: 'fruit',
Expand All @@ -335,9 +335,9 @@ describe('axe.configure', function() {
var localeData = audit.data;

assert.equal(localeData.rules.greeting.help, 'ABCDEFGHIKLMNOPQRSTVXYZ');
assert.equal(localeData.rules.greeting.description(), 'hello');
assert.equal(localeData.rules.greeting.description, 'hello');
assert.equal(localeData.checks.banana.messages.pass, 'yay');
assert.equal(localeData.checks.banana.messages.fail(), 'icecream');
assert.equal(localeData.checks.banana.messages.fail, 'icecream');
assert.deepEqual(localeData.checks.banana.messages.incomplete, {
foo: 'a',
bar: 'b',
Expand All @@ -361,6 +361,46 @@ describe('axe.configure', function() {
assert.equal(axe._audit.lang, 'lol');
});

it('should call doT.compile if a messages uses doT syntax', function() {
axe.configure({
locale: {
lang: 'lol',
rules: { greeting: { description: 'hello' } },
checks: {
banana: {
fail: 'icecream {{=it.data.value}}'
}
}
}
});

var audit = axe._audit;
var localeData = audit.data;

assert.isTrue(
typeof localeData.checks.banana.messages.fail === 'function'
);
});

it('should leave the messages as a string if it does not use doT syntax', function() {
axe.configure({
locale: {
lang: 'lol',
rules: { greeting: { description: 'hello' } },
checks: {
banana: {
fail: 'icecream ${data.value}'
}
}
}
});

var audit = axe._audit;
var localeData = audit.data;

assert.isTrue(typeof localeData.checks.banana.messages.fail === 'string');
});

it('should update failure messages', function() {
axe._load({
data: {
Expand Down Expand Up @@ -400,9 +440,9 @@ describe('axe.configure', function() {
var audit = axe._audit;
var localeData = audit.data;

assert.equal(localeData.failureSummaries.any.failureMessage(), 'foo');
assert.equal(localeData.failureSummaries.none.failureMessage(), 'bar');
assert.equal(localeData.incompleteFallbackMessage(), 'baz');
assert.equal(localeData.failureSummaries.any.failureMessage, 'foo');
assert.equal(localeData.failureSummaries.none.failureMessage, 'bar');
assert.equal(localeData.incompleteFallbackMessage, 'baz');
});

it('should merge failure messages', function() {
Expand Down Expand Up @@ -440,7 +480,7 @@ describe('axe.configure', function() {
var audit = axe._audit;
var localeData = audit.data;

assert.equal(localeData.failureSummaries.any.failureMessage(), 'foo');
assert.equal(localeData.failureSummaries.any.failureMessage, 'foo');
assert.equal(
localeData.failureSummaries.none.failureMessage(),
'failed none'
Expand Down Expand Up @@ -571,7 +611,7 @@ describe('axe.configure', function() {
var banana = axe._audit.data.checks.banana;
assert.equal(banana.impact, 'potato');
assert.equal(banana.foo, 'bar');
assert.equal(banana.messages.pass(), 'yay banana');
assert.equal(banana.messages.pass, 'yay banana');
});

it('should error when provided an unknown rule id', function() {
Expand Down Expand Up @@ -645,7 +685,7 @@ describe('axe.configure', function() {
var audit = axe._audit;
var localeData = audit.data;

assert.equal(localeData.rules.greeting.help(), 'hi');
assert.equal(localeData.rules.greeting.help, 'hi');
});
});

Expand Down