-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocale.ts
231 lines (221 loc) · 9.64 KB
/
locale.ts
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import type { DefaultTheme, HeadConfig, LocaleConfig } from 'vitepress'
import { createTranslate } from './i18n/utils'
const docsLink = 'https://js-utils-es.vercel.app'
const githubRepo = 'agiletech-web-dev/js-utils-es'
const githubLink: 'https://github.com/agiletech-web-dev/js-utils-es' = `https://github.com/${githubRepo}`
export function getLocaleConfig(lang: string) {
const t = createTranslate(lang)
const urlPrefix = lang && lang !== 'en' ? `/${lang}` : ''
const title = t('JS Utilities')
const description = t('A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.')
const head: HeadConfig[] = [
['meta', { property: 'og:title', content: title }],
['meta', { property: 'og:description', content: description }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:url', content: docsLink }],
['meta', { property: 'twitter:card', content: 'summary_large_image' }],
['link', { rel: 'icon', href: '/logo.svg', type: 'image/svg+xml' }],
['meta', { name: 'theme-color', content: '#914796' }],
['link', { rel: 'apple-touch-icon', href: '/apple-touch-icon.png', sizes: '180x180' }],
]
const nav: DefaultTheme.NavItem[] = [
{
text: t('Guide'),
link: `${urlPrefix}/guide/getting-started`,
activeMatch: 'guide',
},
{
text: t('Reference'),
link: `${urlPrefix}/reference/array/chunk`,
activeMatch: 'reference',
},
]
const sidebar: DefaultTheme.SidebarItem[] = [
{
text: t('Guide'),
items: [
{
text: t('Getting Started'),
link: `${urlPrefix}/guide/getting-started`,
},
],
},
{
text: t('Reference'),
items: [
{
text: t('Array Utilities'),
items: [
{ text: 'chunk', link: '/reference/array/chunk' },
{ text: 'countBy', link: '/reference/array/countBy' },
{ text: 'compact', link: '/reference/array/compact' },
{ text: 'difference', link: '/reference/array/difference' },
{ text: 'differenceBy', link: '/reference/array/differenceBy' },
{ text: 'differenceWith', link: '/reference/array/differenceWith' },
{ text: 'drop', link: '/reference/array/drop' },
{ text: 'dropWhile', link: '/reference/array/dropWhile' },
{ text: 'dropRight', link: '/reference/array/dropRight' },
{ text: 'dropRightWhile', link: '/reference/array/dropRightWhile' },
{ text: 'fill', link: '/reference/array/fill' },
{ text: 'toFilled', link: '/reference/array/toFilled' },
{ text: 'flatten', link: '/reference/array/flatten' },
{ text: 'flattenDeep', link: '/reference/array/flattenDeep' },
{ text: 'forEachRight', link: '/reference/array/forEachRight' },
{ text: 'groupBy', link: '/reference/array/groupBy' },
{ text: 'intersection', link: '/reference/array/intersection' },
{ text: 'intersectionBy', link: '/reference/array/intersectionBy' },
{
text: 'intersectionWith',
link: '/reference/array/intersectionWith',
},
{ text: 'keyBy', link: '/reference/array/keyBy' },
{ text: 'minBy', link: '/reference/array/minBy' },
{ text: 'maxBy', link: '/reference/array/maxBy' },
{ text: 'orderBy', link: '/reference/array/orderBy' },
{ text: 'partition', link: '/reference/array/partition' },
{ text: 'sample', link: '/reference/array/sample' },
{ text: 'sampleSize', link: '/reference/array/sampleSize' },
{ text: 'shuffle', link: '/reference/array/shuffle' },
{ text: 'take', link: '/reference/array/take' },
{ text: 'takeWhile', link: '/reference/array/takeWhile' },
{ text: 'takeRight', link: '/reference/array/takeRight' },
{ text: 'takeRightWhile', link: '/reference/array/takeRightWhile' },
{ text: 'union', link: '/reference/array/union' },
{ text: 'unionBy', link: '/reference/array/unionBy' },
{ text: 'unionWith', link: '/reference/array/unionWith' },
{ text: 'uniq', link: '/reference/array/uniq' },
{ text: 'uniqBy', link: '/reference/array/uniqBy' },
{ text: 'uniqWith', link: '/reference/array/uniqWith' },
{ text: 'unzip', link: '/reference/array/unzip' },
{ text: 'unzipWith', link: '/reference/array/unzipWith' },
{ text: 'without', link: '/reference/array/without' },
{ text: 'xor', link: '/reference/array/xor' },
{ text: 'xorBy', link: '/reference/array/xorBy' },
{ text: 'xorWith', link: '/reference/array/xorWith' },
{ text: 'zip', link: '/reference/array/zip' },
{ text: 'zipObject', link: '/reference/array/zipObject' },
{ text: 'zipWith', link: '/reference/array/zipWith' },
{ text: 'head', link: '/reference/array/head' },
{ text: 'tail', link: '/reference/array/tail' },
{ text: 'last', link: '/reference/array/last' },
{ text: 'initial', link: '/reference/array/initial' },
],
},
{
text: t('Function Utilities'),
items: [
{ text: 'debounce', link: '/reference/function/debounce' },
{ text: 'throttle', link: '/reference/function/throttle' },
{ text: 'negate', link: '/reference/function/negate' },
{ text: 'once', link: '/reference/function/once' },
{ text: 'noop', link: '/reference/function/noop' },
],
},
{
text: t('Math Utilities'),
items: [
{ text: 'clamp', link: '/reference/math/clamp' },
{ text: 'inRange', link: '/reference/math/inRange' },
{ text: 'mean', link: '/reference/math/mean' },
{ text: 'meanBy', link: '/reference/math/meanBy' },
{ text: 'random', link: '/reference/math/random' },
{ text: 'randomInt', link: '/reference/math/randomInt' },
{ text: 'range', link: '/reference/math/range' },
{ text: 'round', link: '/reference/math/round' },
{ text: 'sum', link: '/reference/math/sum' },
{ text: 'sumBy', link: '/reference/math/sumBy' },
{ text: 'lerp', link: '/reference/math/lerp' },
{ text: 'remap', link: '/reference/math/remap' },
],
},
{
text: t('Object Utilities'),
items: [
{ text: 'clone', link: '/reference/object/clone' },
{ text: 'omit', link: '/reference/object/omit' },
{ text: 'omitBy', link: '/reference/object/omitBy' },
{ text: 'pick', link: '/reference/object/pick' },
{ text: 'pickBy', link: '/reference/object/pickBy' },
{ text: 'invert', link: '/reference/object/invert' },
],
},
{
text: t('Predicates'),
items: [
{ text: 'isBoolean', link: '/reference/predicate/isBoolean' },
{ text: 'isDate', link: '/reference/predicate/isDate' },
{ text: 'isEqual', link: '/reference/predicate/isEqual' },
{ text: 'isFunction', link: '/reference/predicate/isFunction' },
{ text: 'isNil', link: '/reference/predicate/isNil' },
{ text: 'isNotNil', link: '/reference/predicate/isNotNil' },
{ text: 'isNull', link: '/reference/predicate/isNull' },
{ text: 'isNumber', link: '/reference/predicate/isNumber' },
{ text: 'isObject', link: '/reference/predicate/isObject' },
{ text: 'isRegExp', link: '/reference/predicate/isRegExp' },
{ text: 'isString', link: '/reference/predicate/isString' },
{ text: 'isUndefined', link: '/reference/predicate/isUndefined' },
{ text: 'isWindow', link: '/reference/predicate/isWindow' },
],
},
{
text: t('Promise Utilities'),
items: [
{ text: 'delay', link: '/reference/promise/delay' },
{ text: 'pChain', link: '/reference/promise/pChain' },
],
},
{
text: t('String Utilities'),
items: [
{ text: 'snakeCase', link: '/reference/string/snakeCase' },
{ text: 'kebabCase', link: '/reference/string/kebabCase' },
{ text: 'lowerCase', link: '/reference/string/lowerCase' },
{ text: 'capitalize', link: '/reference/string/capitalize' },
],
},
],
},
]
const themeConfig: DefaultTheme.Config = {
logo: '/logo.svg',
nav,
sidebar,
socialLinks: [
{ icon: 'github', link: githubLink },
],
footer: {
message: t('Made with ❤️'),
copyright:
'MIT License © 2024-PRESENT <a href="https://github.com/hunghg255">hunghg255</a>',
},
editLink: {
pattern: `${githubLink}/edit/main/docs/:path`,
text: t('Edit this page on GitHub'),
},
}
// if (lang === 'zh-CN') {
// Object.assign(themeConfig, {
// outline: {
// label: '页面导航',
// },
// lastUpdatedText: '最后更新于',
// darkModeSwitchLabel: '外观',
// sidebarMenuLabel: '目录',
// returnToTopLabel: '返回顶部',
// langMenuLabel: '选择语言',
// docFooter: {
// prev: '上一页',
// next: '下一页',
// },
// } satisfies DefaultTheme.Config)
// }
const localeConfig: LocaleConfig<DefaultTheme.Config>[string] = {
label: t('English'),
lang: t('en'),
title,
description,
head,
themeConfig,
}
return localeConfig
}