File size: 9,227 Bytes
0953253
 
 
 
ebe5562
 
 
 
 
 
 
0953253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebe5562
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0953253
 
ebe5562
 
0953253
 
 
 
 
ebe5562
 
 
0953253
 
 
 
 
ebe5562
 
 
 
 
 
 
0953253
 
 
 
 
 
 
 
 
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import { useSyncExternalStore } from "react"
import type { Rel } from "@/lib/types"

/**
 * English and Chinese copy. The language is a suffix on the page's address, the first part of the
 * hash: `#/ch`, `#/ch/video`, `#/en/video`; none means English. (huggingface.co passes only the
 * query and the hash on to the Space, so a path such as /ch cannot work.) An older `?lang=zh` link
 * is moved into the hash on load. Switching rewrites the hash and re-renders the whole page (App
 * keys it on the language), so components read `T` while they render and nothing caches copy at
 * import. Every key must exist in both languages: `zh` is typed from `en`, so a missing one fails
 * the build. In Chinese, as in English, MiniMax's weights are never called open source: 公开 / 开放权重.
 */
export type Lang = "en" | "zh"

const en = {
  site: "MiniMax Ecosystem",
  pageTitle: (name: string) => `${name} · MiniMax Ecosystem`,
  noData: "The data did not load. Try refreshing the page.",
  broken: "Something went wrong. Try refreshing the page.",

  menu: "Models",
  elsewhere: "Elsewhere",
  officialLink: (label: string) => `${label} on minimax.io`,
  hfOrg: "MiniMaxAI on Hugging Face",
  otherLang: "中文",
  switchLang: "切换到中文",

  // the landing page
  dlTagline: "downloads of MiniMax models and their community",
  chart: "Chart",
  metricModels: "Models",
  metricDownloads: "Downloads",
  chartModelsAria: (v: string) => `Community models built on MiniMax, ${v} today`,
  chartDownloadsAria: (v: string) => `Downloads of MiniMax models and everything built on them, ${v} in all`,
  communityModels: "community models",
  communityDownloads: "community downloads",
  minimaxModelDownloads: "MiniMax model downloads",
  minimaxDownloads: "MiniMax downloads",
  builders: "builders",
  openModels: (n: number): string => (n === 1 ? "open model" : "open models"),
  moreBuilders: (n: string) => `+${n} more builders`,
  byModality: "By modality",
  everyRelease: "Every release",
  earlier: "Earlier releases",
  later: "Later releases",
  railCommunity: "community",
  railDownloads: "downloads",

  // a model's page
  heroCount: "community models", // after the number
  communityDownloads30: "community downloads, 30 days",
  releaseDownloads: (name: string) => `${name} downloads`,
  growth: "Growth",
  byTypeOverTime: "Community models by type",
  newEachWeek: "New each week",
  newN: "New",
  weekOf: (d: string) => `Week of ${d}`,
  downloadsOverTime: "Downloads over time",
  dailyDownloads: "Daily downloads",
  byType: "By type",
  whoBuilds: "Who builds on it",
  topModels: "Most downloaded, last 30 days",
  topBuilders: "Most active builders",
  allModels: "All community models",
  galaxy: "Galaxy",

  // tables and lists
  type: "Type",
  model: "Model",
  modelsCol: "Models",
  onHfTree: "On HF model tree",
  dl30Col: "Downloads, 30 days",
  allTime: "All-time",
  days30: "30 days",
  lastDay: "Last day",
  subtotal: "Subtotal",
  total: "Total",
  modelsUnit: (n: number): string => (n === 1 ? "model" : "models"), // after the number
  search: "Search models or builders",
  showMore: (n: number) => `Show ${n} more`,

  // the galaxy
  rings: ["", "Built on it directly", "Second generation", "Third generation and on"],
  builtOn: "Built on",
  downloads: "Downloads",
  last30: "Last 30 days",
  likes: "Likes",
  created: "Created",
  officialTag: (name: string) => `${name} (official)`,
  minimaxOfficial: "MiniMax official",
  galaxyCommunity: "Community models",
  placing: (n: string) => `Placing ${n} models…`,
  galaxyAria: (n: string, name: string) => `${n} community models around ${name}`,

  downloadPng: "Download PNG",
  downloadAria: (name: string) => `Download ${name} as PNG`,

  rel: {
    adapter: "Adapters", finetune: "Fine-tunes", quantized: "Quantized", repackage: "Repackaged",
    merge: "Merges", mirror: "Mirrors", component: "Components",
  } as Record<Rel, string>,
  /** English names come from the data (site.json); a key missing here falls back to them. */
  cat: {} as Record<string, string>,
}

const zh: typeof en = {
  site: "MiniMax 生态",
  pageTitle: (name) => `${name} · MiniMax 生态`,
  noData: "数据没有加载出来,请刷新页面重试。",
  broken: "页面出错了,请刷新重试。",

  menu: "模型",
  elsewhere: "其他链接",
  officialLink: (label) => `官网 ${label}`,
  hfOrg: "Hugging Face 上的 MiniMaxAI",
  otherLang: "EN",
  switchLang: "Switch to English",

  dlTagline: "MiniMax 模型及其社区模型的总下载量",
  chart: "图表",
  metricModels: "模型数",
  metricDownloads: "下载量",
  chartModelsAria: (v) => `基于 MiniMax 的社区模型,目前共 ${v} 个`,
  chartDownloadsAria: (v) => `MiniMax 模型及其社区模型的下载量,累计 ${v}`,
  communityModels: "社区模型",
  communityDownloads: "社区下载量",
  minimaxModelDownloads: "MiniMax 模型下载量",
  minimaxDownloads: "MiniMax 下载量",
  builders: "开发者",
  openModels: () => "公开模型",
  moreBuilders: (n) => `另有 ${n} 位开发者`,
  byModality: "按模态",
  everyRelease: "历次发布",
  earlier: "更早的发布",
  later: "更近的发布",
  railCommunity: "社区模型",
  railDownloads: "下载量",

  heroCount: "个社区模型",
  communityDownloads30: "近 30 天社区下载量",
  releaseDownloads: (name) => `${name} 下载量`,
  growth: "增长",
  byTypeOverTime: "各类社区模型",
  newEachWeek: "每周新增",
  newN: "新增",
  weekOf: (d) => `${d}起的一周`,
  downloadsOverTime: "下载量走势",
  dailyDownloads: "每日下载量",
  byType: "按类型",
  whoBuilds: "谁在基于它开发",
  topModels: "近 30 天下载最多",
  topBuilders: "最活跃的开发者",
  allModels: "全部社区模型",
  galaxy: "星系图",

  type: "类型",
  model: "模型",
  modelsCol: "模型数",
  onHfTree: "HF 模型树",
  dl30Col: "近 30 天下载量",
  allTime: "累计下载量",
  days30: "近 30 天",
  lastDay: "最近一天",
  subtotal: "小计",
  total: "合计",
  modelsUnit: () => "个模型",
  search: "搜索模型或开发者",
  showMore: (n) => `再显示 ${n} 个`,

  rings: ["", "直接基于它", "第二代", "第三代及以后"],
  builtOn: "基于",
  downloads: "下载量",
  last30: "近 30 天",
  likes: "点赞",
  created: "创建于",
  officialTag: (name) => `${name}(官方)`,
  minimaxOfficial: "MiniMax 官方",
  galaxyCommunity: "社区模型",
  placing: (n) => `正在排布 ${n} 个模型…`,
  galaxyAria: (n, name) => `${name} 周围的 ${n} 个社区模型`,

  downloadPng: "下载 PNG",
  downloadAria: (name) => `下载 PNG:${name}`,

  rel: {
    adapter: "适配器", finetune: "微调", quantized: "量化", repackage: "格式转换",
    merge: "合并", mirror: "镜像", component: "组件",
  },
  cat: { language: "语言", video: "视频", image: "图片", music: "音乐", audio: "语音" },
}

/** What the address may say: "ch" (or "zh") for Chinese, "en" for English. */
const URL_LANG: Record<string, Lang> = { en: "en", ch: "zh", zh: "zh" }

/** The hash split into its language suffix, if it has one, and the route after it (still encoded). */
export function splitHash(hash = location.hash): { lang: Lang | null; rest: string[] } {
  const parts = hash.replace(/^#\/?/, "").split("/").filter(Boolean)
  const l = URL_LANG[parts[0]?.toLowerCase() ?? ""]
  return l ? { lang: l, rest: parts.slice(1) } : { lang: null, rest: parts }
}

/** The hash for a route in a language: English has no suffix, Chinese leads with "ch". */
export const hashFor = (l: Lang, rest: string[]) => "#/" + [...(l === "zh" ? ["ch"] : []), ...rest].join("/")

// An older ?lang=zh link: move the language into the hash, where it lives now.
{
  const u = new URL(location.href)
  const q = URL_LANG[u.searchParams.get("lang")?.toLowerCase() ?? ""]
  if (u.searchParams.has("lang")) {
    const { lang: h, rest } = splitHash()
    u.searchParams.delete("lang")
    u.hash = hashFor(h ?? q ?? "en", rest)
    history.replaceState(history.state, "", u)
  }
}

let lang: Lang = splitHash().lang ?? "en"
/** The copy in the current language; follows the hash. */
export let T = lang === "zh" ? zh : en
const listeners = new Set<() => void>()
const mark = () => (document.documentElement.lang = lang === "zh" ? "zh-CN" : "en")
mark()

// Registered before the router's own listener, so the copy has switched by the time it renders.
addEventListener("hashchange", () => {
  const l = splitHash().lang ?? "en"
  if (l === lang) return
  lang = l
  T = l === "zh" ? zh : en
  mark()
  listeners.forEach((f) => f())
})

export const getLang = () => lang

/** Switch language by rewriting the hash suffix; the page stays where it is in the routes. */
export function setLang(l: Lang) {
  if (l !== lang) location.hash = hashFor(l, splitHash().rest)
}

export function useLang(): Lang {
  return useSyncExternalStore((f) => (listeners.add(f), () => listeners.delete(f)), getLang)
}

export const relName = (r: Rel) => T.rel[r]
/** A modality's name: the data's English name, or its Chinese one by key. */
export const catName = (c: { key: string; name: string }) => T.cat[c.key] ?? c.name