-
Notifications
You must be signed in to change notification settings - Fork 366
Expand file tree
/
Copy pathlanguage-switcher.yaml
More file actions
171 lines (169 loc) · 5.49 KB
/
Copy pathlanguage-switcher.yaml
File metadata and controls
171 lines (169 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
params:
- name: items
type: array
required: true
description: The languages to display within the language switcher.
params:
- name: text
type: string
required: true
description: If `html` is set, this is not required. Name of the language, written in that language (for example, "Cymraeg" for Welsh). If `html` is provided, the `text` option will be ignored.
- name: html
type: string
required: true
description: If `text` is set, this is not required. HTML to use for the language item. If `html` is provided, the `text` option will be ignored.
- name: lang
type: string
required: true
description: The language tag for the language item text (for example, `cy` for Welsh). Added as a `lang` attribute so that assistive technologies pronounce the language name correctly.
- name: hrefLang
type: string
required: false
description: The language tag for the linked page (for example, `cy` for Welsh). Added as an `hreflang` attribute for search engines and other machine readers. Defaults to `lang` when omitted.
- name: dir
type: string
required: false
description: The text direction for the language item element. Use this on every item when the switcher includes languages that use scripts with different directions.
- name: href
type: string
required: false
description: Link to the current page in this language.
- name: current
type: boolean
required: false
description: Whether this is the language of the current page. Defaults to `true` when `href` is not provided.
- name: attributes
type: object
required: false
description: HTML attributes to add to the language item anchor.
- name: ariaLabel
type: string
required: false
description: Plain text label identifying the navigation landmark to screen readers. Write it in the language of the current page. Defaults to "Language switcher".
- name: menuButtonText
type: string
required: false
description: The text of the button that opens the mobile menu. Write it in the language of the current page. Defaults to "Languages".
- name: menuButtonLabel
type: string
required: false
description: The screen reader label for the button that opens the mobile menu, when it is different to the text of the button. Defaults to the same value as `menuButtonText`.
- name: listId
type: string
required: false
description: The ID used to associate the mobile menu button with the list of languages it controls. Defaults to "language-switcher-list".
- name: collapseOnMobile
type: boolean
required: false
description: Setting this to `false` stops the list of languages from being collapsed into a menu on mobile, keeping it always visible. Defaults to `true` when there is more than one language.
- name: classes
type: string
required: false
description: Classes to add to the language switcher container.
- name: attributes
type: object
required: false
description: HTML attributes to add to the language switcher container.
examples:
- name: default
screenshot: true
options:
items:
- text: English
lang: en
current: true
- text: Cymraeg
lang: cy
href: '#/cy'
- name: with multiple languages
options:
items:
- text: English
lang: en
current: true
- text: Français
lang: fr
href: '#/fr'
- text: हिंदी
lang: hi
href: '#/hi'
- text: 日本語
lang: ja
href: '#/ja'
- text: اردو
lang: ur
href: '#/ur'
- text: 中文
lang: zh
href: '#/zh'
- name: with translated navigation label
description: When the current page is not in English, translate the `ariaLabel` into the language of the current page.
options:
ariaLabel: Dewis iaith
attributes:
lang: cy
items:
- text: English
lang: en
href: '#/en'
- text: Cymraeg
lang: cy
current: true
- name: with mixed text directions
options:
items:
- text: English
lang: en
dir: ltr
current: true
- text: العربية
lang: ar
dir: rtl
href: '#/ar'
# Hidden examples are not shown in the review app, but are used for tests and HTML fixtures
- name: classes
hidden: true
options:
classes: app-language-switcher--custom-modifier
items:
- text: English
lang: en
current: true
- text: Cymraeg
lang: cy
href: '#/cy'
- name: attributes
hidden: true
options:
attributes:
id: my-language-switcher
'data-foo': 'bar'
items:
- text: English
lang: en
current: true
- text: Cymraeg
lang: cy
href: '#/cy'
- name: item attributes
hidden: true
options:
items:
- text: English
lang: en
current: true
- text: Cymraeg
lang: cy
href: '#/cy'
attributes:
data-attribute: my-attribute
- name: html
hidden: true
options:
items:
- text: English
lang: en
current: true
- html: <span>Cymraeg</span>
lang: cy
href: '#/cy'