@docpensieve/shared 0.4.0-beta.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/constants.js +27 -0
- package/src/index.js +1 -0
- package/src/ui-strings.js +178 -0
- package/types/constants.d.ts +25 -0
- package/types/index.d.ts +1 -0
- package/types/ui-strings.d.ts +196 -0
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -46,6 +46,15 @@ export const JSONLD_TYPES = ['Article', 'TechArticle', 'BlogPosting'];
|
|
|
46
46
|
/** CSS frameworks known to the ThemeEngine. */
|
|
47
47
|
export const THEME_FRAMEWORKS = ['tailwind', 'custom'];
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Public address of the documentation.
|
|
51
|
+
*
|
|
52
|
+
* Written wherever a reader could be stuck — the foot of the help, the
|
|
53
|
+
* generated configuration, the end of `init` — so it lives in one place
|
|
54
|
+
* rather than in each of them.
|
|
55
|
+
*/
|
|
56
|
+
export const DOCUMENTATION_URL = 'https://docpensieve.com/';
|
|
57
|
+
|
|
49
58
|
/**
|
|
50
59
|
* Layouts accepted in a page's frontmatter.
|
|
51
60
|
*
|
|
@@ -68,13 +77,24 @@ export const PAGE_LAYOUTS = Object.freeze(['doc', 'home']);
|
|
|
68
77
|
* This table is shared: `core` reads it in its templates, `theme` extends it
|
|
69
78
|
* in its providers.
|
|
70
79
|
*/
|
|
80
|
+
/**
|
|
81
|
+
* Tones an admonition can take: what colours it, nothing more.
|
|
82
|
+
*
|
|
83
|
+
* Here rather than with the component: the configuration validates the kinds a
|
|
84
|
+
* project declares, and `core` never imports `components` (ADR-002).
|
|
85
|
+
*/
|
|
86
|
+
export const ADMONITION_TONES = Object.freeze(['note', 'info', 'tip', 'attention', 'danger']);
|
|
87
|
+
|
|
71
88
|
export const DEFAULT_THEME_CLASSES = Object.freeze({
|
|
72
89
|
skip: 'dp-skip',
|
|
73
90
|
header: 'dp-header',
|
|
91
|
+
headerStatic: 'dp-header dp-header--static',
|
|
74
92
|
brand: 'dp-brand',
|
|
75
93
|
brandLogo: 'dp-brand-logo',
|
|
76
94
|
versions: 'dp-versions',
|
|
77
95
|
versionsList: 'dp-versions-list',
|
|
96
|
+
languages: 'dp-languages',
|
|
97
|
+
languagesList: 'dp-languages-list',
|
|
78
98
|
shell: 'dp-shell',
|
|
79
99
|
shellWide: 'dp-shell dp-shell--wide',
|
|
80
100
|
sidebar: 'dp-sidebar',
|
|
@@ -83,6 +103,9 @@ export const DEFAULT_THEME_CLASSES = Object.freeze({
|
|
|
83
103
|
navItemParent: 'dp-nav-item--parent',
|
|
84
104
|
navLink: 'dp-nav-link',
|
|
85
105
|
navLabel: 'dp-nav-label',
|
|
106
|
+
navGroup: 'dp-nav-group',
|
|
107
|
+
navSummary: 'dp-nav-summary',
|
|
108
|
+
sidebarMenu: 'dp-sidebar-menu',
|
|
86
109
|
notice: 'dp-notice',
|
|
87
110
|
skillIcon: 'dp-skill-icon',
|
|
88
111
|
main: 'dp-main',
|
|
@@ -109,4 +132,8 @@ export const DEFAULT_THEME_CLASSES = Object.freeze({
|
|
|
109
132
|
headerLinks: 'dp-header-links',
|
|
110
133
|
menu: 'dp-menu',
|
|
111
134
|
menuPanel: 'dp-menu-panel',
|
|
135
|
+
mega: 'dp-mega',
|
|
136
|
+
megaPanel: 'dp-mega-panel',
|
|
137
|
+
megaColumn: 'dp-mega-column',
|
|
138
|
+
megaTitle: 'dp-mega-title',
|
|
112
139
|
});
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wording of the page shell, by language.
|
|
3
|
+
*
|
|
4
|
+
* The pages are written by the project; these are the words the tool adds
|
|
5
|
+
* around them — the menu, the notices, the search field. Left in English on a
|
|
6
|
+
* French site, they would announce the language of the shell rather than the
|
|
7
|
+
* language of the documentation.
|
|
8
|
+
*
|
|
9
|
+
* A language the tool does not ship keeps the English wording: that is what
|
|
10
|
+
* `lang` did before this table existed, and a project already running
|
|
11
|
+
* `lang: 'de'` must not stop building because of it. Its own wording goes in
|
|
12
|
+
* the `ui` field of the configuration.
|
|
13
|
+
*
|
|
14
|
+
* @module @docpensieve/shared/ui-strings
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} UiStrings
|
|
19
|
+
* @property {string} skipToContent Link to the content, first in the tab order.
|
|
20
|
+
* @property {string} site Accessible name of the header navigation.
|
|
21
|
+
* @property {string} menu Accessible name of the narrow-screen menu button.
|
|
22
|
+
* @property {string} switchScheme Accessible name of the light/dark button.
|
|
23
|
+
* @property {string} switchVersion Completes the accessible name of the version switcher.
|
|
24
|
+
* @property {string} versionLabel The word before a version number, mid-sentence.
|
|
25
|
+
* @property {string} versionSwitch The same word opening a label, where a capital is due.
|
|
26
|
+
* @property {string} documentationMenu Handle of the folded menu, on a narrow screen.
|
|
27
|
+
* @property {string} documentationNavigation Accessible name of the menu.
|
|
28
|
+
* @property {string} onThisPage Heading of the table of contents.
|
|
29
|
+
* @property {string} tags Accessible name of the tag list.
|
|
30
|
+
* @property {string} backToTop Accessible name of the back-to-top link.
|
|
31
|
+
* @property {string} search Placeholder of the header field.
|
|
32
|
+
* @property {string} searchTitle Heading of the search page.
|
|
33
|
+
* @property {string} searchTheDocumentation Label of the search fields.
|
|
34
|
+
* @property {Record<string, string>} pages Counting results, by plural
|
|
35
|
+
* category of the language (CLDR): `one`, `other`, and `few`, `many`,
|
|
36
|
+
* `two`, `zero` where the language has them.
|
|
37
|
+
* @property {string} searchIndexFailed Shown when the index cannot be loaded.
|
|
38
|
+
* @property {string} noResultFor Shown when a query matches nothing. `{query}` is the query.
|
|
39
|
+
* @property {string} resultsFor Counts the matches. `{count}` reads `3 pages`, `{query}` is the query.
|
|
40
|
+
* @property {string} prereleaseNotice Banner of a version in preparation.
|
|
41
|
+
* @property {string} archivedNotice Banner of a version no longer maintained.
|
|
42
|
+
* @property {string} currentVersionIs Introduces the link to the current version.
|
|
43
|
+
* @property {string} written Byline prefix for the publication date.
|
|
44
|
+
* @property {string} updated Byline prefix for the modification date.
|
|
45
|
+
* @property {string} language Accessible name of the language switcher.
|
|
46
|
+
* @property {string} dateLocale Locale used to write a date in full.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The shipped languages.
|
|
51
|
+
*
|
|
52
|
+
* @type {Record<string, UiStrings>}
|
|
53
|
+
*/
|
|
54
|
+
export const UI_STRINGS = Object.freeze({
|
|
55
|
+
en: Object.freeze({
|
|
56
|
+
skipToContent: 'Skip to content',
|
|
57
|
+
site: 'Site',
|
|
58
|
+
menu: 'Menu',
|
|
59
|
+
switchScheme: 'Switch the colour scheme',
|
|
60
|
+
switchVersion: 'switch version',
|
|
61
|
+
versionLabel: 'version',
|
|
62
|
+
versionSwitch: 'Version',
|
|
63
|
+
documentationMenu: 'Documentation menu',
|
|
64
|
+
documentationNavigation: 'Documentation navigation',
|
|
65
|
+
onThisPage: 'On this page',
|
|
66
|
+
tags: 'Tags',
|
|
67
|
+
backToTop: 'Back to top',
|
|
68
|
+
search: 'Search',
|
|
69
|
+
searchTitle: 'Search',
|
|
70
|
+
searchTheDocumentation: 'Search the documentation',
|
|
71
|
+
pages: { one: 'page', other: 'pages' },
|
|
72
|
+
searchIndexFailed: 'The search index could not be loaded: every page is listed below.',
|
|
73
|
+
noResultFor: 'No page matches “{query}”.',
|
|
74
|
+
resultsFor: '{count} for “{query}”.',
|
|
75
|
+
prereleaseNotice: 'This version is in preparation and may change.',
|
|
76
|
+
archivedNotice: 'This version is no longer maintained.',
|
|
77
|
+
currentVersionIs: 'The current version is',
|
|
78
|
+
written: 'Written',
|
|
79
|
+
updated: 'Updated',
|
|
80
|
+
language: 'Language',
|
|
81
|
+
dateLocale: 'en-GB',
|
|
82
|
+
}),
|
|
83
|
+
fr: Object.freeze({
|
|
84
|
+
skipToContent: 'Aller au contenu',
|
|
85
|
+
site: 'Site',
|
|
86
|
+
menu: 'Menu',
|
|
87
|
+
switchScheme: 'Basculer entre clair et sombre',
|
|
88
|
+
switchVersion: 'changer de version',
|
|
89
|
+
versionLabel: 'version',
|
|
90
|
+
versionSwitch: 'Version',
|
|
91
|
+
documentationMenu: 'Menu de la documentation',
|
|
92
|
+
documentationNavigation: 'Navigation de la documentation',
|
|
93
|
+
onThisPage: 'Sur cette page',
|
|
94
|
+
tags: 'Étiquettes',
|
|
95
|
+
backToTop: 'Retour en haut',
|
|
96
|
+
search: 'Rechercher',
|
|
97
|
+
searchTitle: 'Recherche',
|
|
98
|
+
searchTheDocumentation: 'Rechercher dans la documentation',
|
|
99
|
+
pages: { one: 'page', other: 'pages' },
|
|
100
|
+
searchIndexFailed:
|
|
101
|
+
"L'index de recherche n'a pas pu être chargé : toutes les pages sont listées ci-dessous.",
|
|
102
|
+
noResultFor: 'Aucune page ne correspond à « {query} ».',
|
|
103
|
+
resultsFor: '{count} pour « {query} ».',
|
|
104
|
+
prereleaseNotice: 'Cette version est en préparation et peut encore changer.',
|
|
105
|
+
archivedNotice: "Cette version n'est plus maintenue.",
|
|
106
|
+
currentVersionIs: 'La version actuelle est',
|
|
107
|
+
written: 'Écrit',
|
|
108
|
+
updated: 'Mis à jour',
|
|
109
|
+
language: 'Langue',
|
|
110
|
+
dateLocale: 'fr-FR',
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
/** Language used when nothing else is known. */
|
|
115
|
+
export const DEFAULT_LANGUAGE = 'en';
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The wording of a language, completed by English for anything it omits.
|
|
119
|
+
*
|
|
120
|
+
* @param {string} [lang] Language code, `fr` or `fr-CA`.
|
|
121
|
+
* @param {Record<string, Partial<UiStrings>>} [overrides] Wording declared by the project.
|
|
122
|
+
* @returns {UiStrings}
|
|
123
|
+
*/
|
|
124
|
+
export function uiStrings(lang, overrides) {
|
|
125
|
+
// `fr-CA` reads the wording of `fr`: a regional variant shares its language,
|
|
126
|
+
// and asking a project to declare each one would serve nobody.
|
|
127
|
+
const code = (lang ?? DEFAULT_LANGUAGE).toLowerCase();
|
|
128
|
+
const base = UI_STRINGS[code] ?? UI_STRINGS[code.split('-')[0]] ?? UI_STRINGS[DEFAULT_LANGUAGE];
|
|
129
|
+
const own = overrides?.[code] ?? overrides?.[code.split('-')[0]];
|
|
130
|
+
|
|
131
|
+
// English fills the gaps: a project translating half the wording gets the
|
|
132
|
+
// other half in a language, never an empty label.
|
|
133
|
+
return own ? { ...UI_STRINGS[DEFAULT_LANGUAGE], ...base, ...own } : base;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Counts pages in the language of the page.
|
|
138
|
+
*
|
|
139
|
+
* The plural category comes from the language itself, through the CLDR rules
|
|
140
|
+
* `Intl` carries: `count === 1` is an English rule and gets French wrong on
|
|
141
|
+
* zero — "0 page", not "0 pages" — and has nothing to say about Polish or
|
|
142
|
+
* Arabic, which have four and six categories.
|
|
143
|
+
*
|
|
144
|
+
* @param {number} count
|
|
145
|
+
* @param {UiStrings} strings
|
|
146
|
+
* @param {string} [lang] Language of the page.
|
|
147
|
+
* @returns {string} For instance `12 pages` or `1 page`.
|
|
148
|
+
*/
|
|
149
|
+
export function pageCount(count, strings, lang = DEFAULT_LANGUAGE) {
|
|
150
|
+
const category = new Intl.PluralRules(lang).select(count);
|
|
151
|
+
// `other` is the one category every language has: it answers for the ones a
|
|
152
|
+
// translation did not fill in.
|
|
153
|
+
return `${count} ${strings.pages[category] ?? strings.pages.other}`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Writing direction of a language, for the `dir` attribute.
|
|
158
|
+
*
|
|
159
|
+
* Read from the language rather than from a list of our own: `Intl` carries
|
|
160
|
+
* what CLDR knows, and a list would go stale the day someone translates into
|
|
161
|
+
* a language nobody thought of.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} [lang]
|
|
164
|
+
* @returns {'ltr' | 'rtl'} `ltr` when the language is unknown — the safe
|
|
165
|
+
* default, and what every page did before this existed.
|
|
166
|
+
*/
|
|
167
|
+
export function textDirection(lang) {
|
|
168
|
+
try {
|
|
169
|
+
// The Locale Info API is not in the TypeScript library yet, though Node
|
|
170
|
+
// carries it: the cast says what the runtime actually returns.
|
|
171
|
+
const locale = /** @type {{ textInfo?: { direction?: string } }} */ (
|
|
172
|
+
/** @type {unknown} */ (new Intl.Locale(lang ?? DEFAULT_LANGUAGE))
|
|
173
|
+
);
|
|
174
|
+
return locale.textInfo?.direction === 'rtl' ? 'rtl' : 'ltr';
|
|
175
|
+
} catch {
|
|
176
|
+
return 'ltr';
|
|
177
|
+
}
|
|
178
|
+
}
|
package/types/constants.d.ts
CHANGED
|
@@ -36,6 +36,14 @@ export declare const INDEX_SLUGS: string[];
|
|
|
36
36
|
export declare const JSONLD_TYPES: string[];
|
|
37
37
|
/** CSS frameworks known to the ThemeEngine. */
|
|
38
38
|
export declare const THEME_FRAMEWORKS: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Public address of the documentation.
|
|
41
|
+
*
|
|
42
|
+
* Written wherever a reader could be stuck — the foot of the help, the
|
|
43
|
+
* generated configuration, the end of `init` — so it lives in one place
|
|
44
|
+
* rather than in each of them.
|
|
45
|
+
*/
|
|
46
|
+
export declare const DOCUMENTATION_URL = "https://docpensieve.com/";
|
|
39
47
|
/**
|
|
40
48
|
* Layouts accepted in a page's frontmatter.
|
|
41
49
|
*
|
|
@@ -57,13 +65,23 @@ export declare const PAGE_LAYOUTS: readonly string[];
|
|
|
57
65
|
* This table is shared: `core` reads it in its templates, `theme` extends it
|
|
58
66
|
* in its providers.
|
|
59
67
|
*/
|
|
68
|
+
/**
|
|
69
|
+
* Tones an admonition can take: what colours it, nothing more.
|
|
70
|
+
*
|
|
71
|
+
* Here rather than with the component: the configuration validates the kinds a
|
|
72
|
+
* project declares, and `core` never imports `components` (ADR-002).
|
|
73
|
+
*/
|
|
74
|
+
export declare const ADMONITION_TONES: readonly string[];
|
|
60
75
|
export declare const DEFAULT_THEME_CLASSES: Readonly<{
|
|
61
76
|
skip: "dp-skip";
|
|
62
77
|
header: "dp-header";
|
|
78
|
+
headerStatic: "dp-header dp-header--static";
|
|
63
79
|
brand: "dp-brand";
|
|
64
80
|
brandLogo: "dp-brand-logo";
|
|
65
81
|
versions: "dp-versions";
|
|
66
82
|
versionsList: "dp-versions-list";
|
|
83
|
+
languages: "dp-languages";
|
|
84
|
+
languagesList: "dp-languages-list";
|
|
67
85
|
shell: "dp-shell";
|
|
68
86
|
shellWide: "dp-shell dp-shell--wide";
|
|
69
87
|
sidebar: "dp-sidebar";
|
|
@@ -72,6 +90,9 @@ export declare const DEFAULT_THEME_CLASSES: Readonly<{
|
|
|
72
90
|
navItemParent: "dp-nav-item--parent";
|
|
73
91
|
navLink: "dp-nav-link";
|
|
74
92
|
navLabel: "dp-nav-label";
|
|
93
|
+
navGroup: "dp-nav-group";
|
|
94
|
+
navSummary: "dp-nav-summary";
|
|
95
|
+
sidebarMenu: "dp-sidebar-menu";
|
|
75
96
|
notice: "dp-notice";
|
|
76
97
|
skillIcon: "dp-skill-icon";
|
|
77
98
|
main: "dp-main";
|
|
@@ -98,4 +119,8 @@ export declare const DEFAULT_THEME_CLASSES: Readonly<{
|
|
|
98
119
|
headerLinks: "dp-header-links";
|
|
99
120
|
menu: "dp-menu";
|
|
100
121
|
menuPanel: "dp-menu-panel";
|
|
122
|
+
mega: "dp-mega";
|
|
123
|
+
megaPanel: "dp-mega-panel";
|
|
124
|
+
megaColumn: "dp-mega-column";
|
|
125
|
+
megaTitle: "dp-mega-title";
|
|
101
126
|
}>;
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wording of the page shell, by language.
|
|
3
|
+
*
|
|
4
|
+
* The pages are written by the project; these are the words the tool adds
|
|
5
|
+
* around them — the menu, the notices, the search field. Left in English on a
|
|
6
|
+
* French site, they would announce the language of the shell rather than the
|
|
7
|
+
* language of the documentation.
|
|
8
|
+
*
|
|
9
|
+
* A language the tool does not ship keeps the English wording: that is what
|
|
10
|
+
* `lang` did before this table existed, and a project already running
|
|
11
|
+
* `lang: 'de'` must not stop building because of it. Its own wording goes in
|
|
12
|
+
* the `ui` field of the configuration.
|
|
13
|
+
*
|
|
14
|
+
* @module @docpensieve/shared/ui-strings
|
|
15
|
+
*/
|
|
16
|
+
export type UiStrings = {
|
|
17
|
+
/**
|
|
18
|
+
* Link to the content, first in the tab order.
|
|
19
|
+
*/
|
|
20
|
+
skipToContent: string;
|
|
21
|
+
/**
|
|
22
|
+
* Accessible name of the header navigation.
|
|
23
|
+
*/
|
|
24
|
+
site: string;
|
|
25
|
+
/**
|
|
26
|
+
* Accessible name of the narrow-screen menu button.
|
|
27
|
+
*/
|
|
28
|
+
menu: string;
|
|
29
|
+
/**
|
|
30
|
+
* Accessible name of the light/dark button.
|
|
31
|
+
*/
|
|
32
|
+
switchScheme: string;
|
|
33
|
+
/**
|
|
34
|
+
* Completes the accessible name of the version switcher.
|
|
35
|
+
*/
|
|
36
|
+
switchVersion: string;
|
|
37
|
+
/**
|
|
38
|
+
* The word before a version number, mid-sentence.
|
|
39
|
+
*/
|
|
40
|
+
versionLabel: string;
|
|
41
|
+
/**
|
|
42
|
+
* The same word opening a label, where a capital is due.
|
|
43
|
+
*/
|
|
44
|
+
versionSwitch: string;
|
|
45
|
+
/**
|
|
46
|
+
* Handle of the folded menu, on a narrow screen.
|
|
47
|
+
*/
|
|
48
|
+
documentationMenu: string;
|
|
49
|
+
/**
|
|
50
|
+
* Accessible name of the menu.
|
|
51
|
+
*/
|
|
52
|
+
documentationNavigation: string;
|
|
53
|
+
/**
|
|
54
|
+
* Heading of the table of contents.
|
|
55
|
+
*/
|
|
56
|
+
onThisPage: string;
|
|
57
|
+
/**
|
|
58
|
+
* Accessible name of the tag list.
|
|
59
|
+
*/
|
|
60
|
+
tags: string;
|
|
61
|
+
/**
|
|
62
|
+
* Accessible name of the back-to-top link.
|
|
63
|
+
*/
|
|
64
|
+
backToTop: string;
|
|
65
|
+
/**
|
|
66
|
+
* Placeholder of the header field.
|
|
67
|
+
*/
|
|
68
|
+
search: string;
|
|
69
|
+
/**
|
|
70
|
+
* Heading of the search page.
|
|
71
|
+
*/
|
|
72
|
+
searchTitle: string;
|
|
73
|
+
/**
|
|
74
|
+
* Label of the search fields.
|
|
75
|
+
*/
|
|
76
|
+
searchTheDocumentation: string;
|
|
77
|
+
/**
|
|
78
|
+
* Counting results, by plural
|
|
79
|
+
* category of the language (CLDR): `one`, `other`, and `few`, `many`,
|
|
80
|
+
* `two`, `zero` where the language has them.
|
|
81
|
+
*/
|
|
82
|
+
pages: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* Shown when the index cannot be loaded.
|
|
85
|
+
*/
|
|
86
|
+
searchIndexFailed: string;
|
|
87
|
+
/**
|
|
88
|
+
* Shown when a query matches nothing. `{query}` is the query.
|
|
89
|
+
*/
|
|
90
|
+
noResultFor: string;
|
|
91
|
+
/**
|
|
92
|
+
* Counts the matches. `{count}` reads `3 pages`, `{query}` is the query.
|
|
93
|
+
*/
|
|
94
|
+
resultsFor: string;
|
|
95
|
+
/**
|
|
96
|
+
* Banner of a version in preparation.
|
|
97
|
+
*/
|
|
98
|
+
prereleaseNotice: string;
|
|
99
|
+
/**
|
|
100
|
+
* Banner of a version no longer maintained.
|
|
101
|
+
*/
|
|
102
|
+
archivedNotice: string;
|
|
103
|
+
/**
|
|
104
|
+
* Introduces the link to the current version.
|
|
105
|
+
*/
|
|
106
|
+
currentVersionIs: string;
|
|
107
|
+
/**
|
|
108
|
+
* Byline prefix for the publication date.
|
|
109
|
+
*/
|
|
110
|
+
written: string;
|
|
111
|
+
/**
|
|
112
|
+
* Byline prefix for the modification date.
|
|
113
|
+
*/
|
|
114
|
+
updated: string;
|
|
115
|
+
/**
|
|
116
|
+
* Accessible name of the language switcher.
|
|
117
|
+
*/
|
|
118
|
+
language: string;
|
|
119
|
+
/**
|
|
120
|
+
* Locale used to write a date in full.
|
|
121
|
+
*/
|
|
122
|
+
dateLocale: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* @typedef {object} UiStrings
|
|
126
|
+
* @property {string} skipToContent Link to the content, first in the tab order.
|
|
127
|
+
* @property {string} site Accessible name of the header navigation.
|
|
128
|
+
* @property {string} menu Accessible name of the narrow-screen menu button.
|
|
129
|
+
* @property {string} switchScheme Accessible name of the light/dark button.
|
|
130
|
+
* @property {string} switchVersion Completes the accessible name of the version switcher.
|
|
131
|
+
* @property {string} versionLabel The word before a version number, mid-sentence.
|
|
132
|
+
* @property {string} versionSwitch The same word opening a label, where a capital is due.
|
|
133
|
+
* @property {string} documentationMenu Handle of the folded menu, on a narrow screen.
|
|
134
|
+
* @property {string} documentationNavigation Accessible name of the menu.
|
|
135
|
+
* @property {string} onThisPage Heading of the table of contents.
|
|
136
|
+
* @property {string} tags Accessible name of the tag list.
|
|
137
|
+
* @property {string} backToTop Accessible name of the back-to-top link.
|
|
138
|
+
* @property {string} search Placeholder of the header field.
|
|
139
|
+
* @property {string} searchTitle Heading of the search page.
|
|
140
|
+
* @property {string} searchTheDocumentation Label of the search fields.
|
|
141
|
+
* @property {Record<string, string>} pages Counting results, by plural
|
|
142
|
+
* category of the language (CLDR): `one`, `other`, and `few`, `many`,
|
|
143
|
+
* `two`, `zero` where the language has them.
|
|
144
|
+
* @property {string} searchIndexFailed Shown when the index cannot be loaded.
|
|
145
|
+
* @property {string} noResultFor Shown when a query matches nothing. `{query}` is the query.
|
|
146
|
+
* @property {string} resultsFor Counts the matches. `{count}` reads `3 pages`, `{query}` is the query.
|
|
147
|
+
* @property {string} prereleaseNotice Banner of a version in preparation.
|
|
148
|
+
* @property {string} archivedNotice Banner of a version no longer maintained.
|
|
149
|
+
* @property {string} currentVersionIs Introduces the link to the current version.
|
|
150
|
+
* @property {string} written Byline prefix for the publication date.
|
|
151
|
+
* @property {string} updated Byline prefix for the modification date.
|
|
152
|
+
* @property {string} language Accessible name of the language switcher.
|
|
153
|
+
* @property {string} dateLocale Locale used to write a date in full.
|
|
154
|
+
*/
|
|
155
|
+
/**
|
|
156
|
+
* The shipped languages.
|
|
157
|
+
*
|
|
158
|
+
* @type {Record<string, UiStrings>}
|
|
159
|
+
*/
|
|
160
|
+
export declare const UI_STRINGS: Record<string, UiStrings>;
|
|
161
|
+
/** Language used when nothing else is known. */
|
|
162
|
+
export declare const DEFAULT_LANGUAGE = "en";
|
|
163
|
+
/**
|
|
164
|
+
* The wording of a language, completed by English for anything it omits.
|
|
165
|
+
*
|
|
166
|
+
* @param {string} [lang] Language code, `fr` or `fr-CA`.
|
|
167
|
+
* @param {Record<string, Partial<UiStrings>>} [overrides] Wording declared by the project.
|
|
168
|
+
* @returns {UiStrings}
|
|
169
|
+
*/
|
|
170
|
+
export declare function uiStrings(lang?: string, overrides?: Record<string, Partial<UiStrings>>): UiStrings;
|
|
171
|
+
/**
|
|
172
|
+
* Counts pages in the language of the page.
|
|
173
|
+
*
|
|
174
|
+
* The plural category comes from the language itself, through the CLDR rules
|
|
175
|
+
* `Intl` carries: `count === 1` is an English rule and gets French wrong on
|
|
176
|
+
* zero — "0 page", not "0 pages" — and has nothing to say about Polish or
|
|
177
|
+
* Arabic, which have four and six categories.
|
|
178
|
+
*
|
|
179
|
+
* @param {number} count
|
|
180
|
+
* @param {UiStrings} strings
|
|
181
|
+
* @param {string} [lang] Language of the page.
|
|
182
|
+
* @returns {string} For instance `12 pages` or `1 page`.
|
|
183
|
+
*/
|
|
184
|
+
export declare function pageCount(count: number, strings: UiStrings, lang?: string): string;
|
|
185
|
+
/**
|
|
186
|
+
* Writing direction of a language, for the `dir` attribute.
|
|
187
|
+
*
|
|
188
|
+
* Read from the language rather than from a list of our own: `Intl` carries
|
|
189
|
+
* what CLDR knows, and a list would go stale the day someone translates into
|
|
190
|
+
* a language nobody thought of.
|
|
191
|
+
*
|
|
192
|
+
* @param {string} [lang]
|
|
193
|
+
* @returns {'ltr' | 'rtl'} `ltr` when the language is unknown — the safe
|
|
194
|
+
* default, and what every page did before this existed.
|
|
195
|
+
*/
|
|
196
|
+
export declare function textDirection(lang?: string): 'ltr' | 'rtl';
|