forge
Explore
Log in

Don't you dare go Hollow

forge

Clone
★ 0

0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits

misc.rs840 lines, 28.7 KiBHistoryRawDownload
1//! Strings for this page group. See `docs` in `super` for the pattern.
2//!
3//! Covers the notifications inbox, the repo security page, the appearance settings, the new
4//! repository form and the repo header tab helpers. Shared strings (Save, Security, Notifications,
5//! New repository) come from `super::Key`.
6
7use std::fmt::Display;
8
9use forge_core::store::contributions::ContributionKind;
10
11use super::Lang;
12
13#[derive(Clone, Copy, Debug, PartialEq, Eq)]
14pub enum K {
15 // Appearance settings.
16 Appearance,
17 ThemeLabel,
18 LanguageLabel,
19 MatchSystem,
20 Light,
21 Dark,
22 MatchBrowser,
23 // Top-bar theme button: what it switches to next.
24 SwitchToLight,
25 SwitchToDark,
26 SwitchToMatchSystem,
27 ChooseTheme,
28 ChooseLanguage,
29 ChooseAccent,
30 ColoursLabel,
31 AccentRowLabel,
32 CustomLabel,
33 HueLabel,
34 VividnessLabel,
35 HexLabel,
36 BackgroundLabel,
37 ChooseBase,
38 // Appearance: which side the shell sidebar sits on.
39 ChooseSidebar,
40 // Appearance: the run-finished tone.
41 SoundLabel,
42 SoundPassed,
43 SoundFailed,
44 ChooseSound,
45 // Notifications: row kinds.
46 KindOpenIssue,
47 KindClosedIssue,
48 KindOpenPull,
49 KindClosedPull,
50 KindDiscussion,
51 KindSecurityAlerts,
52 KindAdminAlert,
53 // Notifications: reason badges.
54 ReasonMentioned,
55 ReasonAssigned,
56 ReasonReviewRequested,
57 ReasonAuthor,
58 ReasonCommented,
59 ReasonStateChange,
60 ReasonSubscribed,
61 ReasonWatching,
62 ReasonReplied,
63 ReasonSecurity,
64 ReasonAdmin,
65 // Notifications: activity verbs (`activity_line` adds the actor).
66 VerbOpened,
67 VerbCommented,
68 VerbClosed,
69 VerbReopened,
70 VerbMerged,
71 VerbReviewed,
72 VerbReviewRequested,
73 VerbAssigned,
74 VerbMentionedYou,
75 VerbPushedTo,
76 VerbUpdated,
77 VerbDiscussionReply,
78 // Notifications: inbox page.
79 MarkAllAsRead,
80 MarkAllRead,
81 MarkRead,
82 NoNotificationsYet,
83 NoUnreadNotifications,
84 NotificationFilter,
85 Unread,
86 AllTab,
87 Older,
88 // Notifications: subscription box and watch control.
89 Subscribe,
90 Unsubscribe,
91 OptParticipating,
92 OptWatching,
93 OptIgnoring,
94 // Repo security page.
95 SecurityOff,
96 NoAlerts,
97 StateOpen,
98 StateDismissed,
99 StateFixed,
100 Dismiss,
101 Reopen,
102 // New repository form.
103 NewOwner,
104 RepoName,
105 DescriptionOptional,
106 VisibilityLegend,
107 DefaultBranch,
108 AddDefaultLabels,
109 MirrorLegend,
110 SourceUrl,
111 UsernameOptional,
112 PasswordOrToken,
113 SyncInterval,
114 CreateRepository,
115 OwnerRefused,
116 InvalidRepoName,
117 ReadmeLabel,
118 LicenseLabel,
119 LicenseNone,
120 UnknownLicense,
121 MirrorWithFiles,
122 // Dashboard contribution calendar (`views::heatmap`).
123 ContributionsTitle,
124 ContributionsLastYear,
125 CurrentStreak,
126 LongestStreak,
127 BestDay,
128 Less,
129 More,
130 MonLabel,
131 WedLabel,
132 FriLabel,
133 NoContributionsDay,
134 ViewAllNotifications,
135 // Shell chrome (`views::mod`): breadcrumb landmark, theme picker, ref selector.
136 BreadcrumbNav,
137 RefLabel,
138 // Top-bar user menu: the viewer's public profile and the settings editor.
139 YourProfile,
140 EditProfile,
141 EditOrganization,
142 // Profile corner, live strip and path bar search.
143 Passed,
144 Failed,
145 Cancelled,
146 YourCiRuns,
147 SearchPublicReposFor,
148 // The bell's popover: the newest notifications, opened from the profile corner.
149}
150
151/// Every variant, for the coverage test below.
152#[cfg(test)]
153const ALL: &[K] = &[
154 K::Appearance,
155 K::ThemeLabel,
156 K::LanguageLabel,
157 K::MatchSystem,
158 K::Light,
159 K::Dark,
160 K::MatchBrowser,
161 K::SwitchToLight,
162 K::SwitchToDark,
163 K::SwitchToMatchSystem,
164 K::ChooseTheme,
165 K::ChooseLanguage,
166 K::ChooseAccent,
167 K::ColoursLabel,
168 K::AccentRowLabel,
169 K::CustomLabel,
170 K::HueLabel,
171 K::VividnessLabel,
172 K::HexLabel,
173 K::BackgroundLabel,
174 K::ChooseBase,
175 K::ChooseSidebar,
176 K::SoundLabel,
177 K::SoundPassed,
178 K::SoundFailed,
179 K::ChooseSound,
180 K::KindOpenIssue,
181 K::KindClosedIssue,
182 K::KindOpenPull,
183 K::KindClosedPull,
184 K::KindDiscussion,
185 K::KindSecurityAlerts,
186 K::KindAdminAlert,
187 K::ReasonMentioned,
188 K::ReasonAssigned,
189 K::ReasonReviewRequested,
190 K::ReasonAuthor,
191 K::ReasonCommented,
192 K::ReasonStateChange,
193 K::ReasonSubscribed,
194 K::ReasonWatching,
195 K::ReasonReplied,
196 K::ReasonSecurity,
197 K::ReasonAdmin,
198 K::VerbOpened,
199 K::VerbCommented,
200 K::VerbClosed,
201 K::VerbReopened,
202 K::VerbMerged,
203 K::VerbReviewed,
204 K::VerbReviewRequested,
205 K::VerbAssigned,
206 K::VerbMentionedYou,
207 K::VerbPushedTo,
208 K::VerbUpdated,
209 K::VerbDiscussionReply,
210 K::MarkAllAsRead,
211 K::MarkAllRead,
212 K::MarkRead,
213 K::NoNotificationsYet,
214 K::NoUnreadNotifications,
215 K::NotificationFilter,
216 K::Unread,
217 K::AllTab,
218 K::Older,
219 K::Subscribe,
220 K::Unsubscribe,
221 K::OptParticipating,
222 K::OptWatching,
223 K::OptIgnoring,
224 K::SecurityOff,
225 K::NoAlerts,
226 K::StateOpen,
227 K::StateDismissed,
228 K::StateFixed,
229 K::Dismiss,
230 K::Reopen,
231 K::NewOwner,
232 K::RepoName,
233 K::DescriptionOptional,
234 K::VisibilityLegend,
235 K::DefaultBranch,
236 K::AddDefaultLabels,
237 K::MirrorLegend,
238 K::SourceUrl,
239 K::UsernameOptional,
240 K::PasswordOrToken,
241 K::SyncInterval,
242 K::CreateRepository,
243 K::OwnerRefused,
244 K::InvalidRepoName,
245 K::ReadmeLabel,
246 K::LicenseLabel,
247 K::LicenseNone,
248 K::UnknownLicense,
249 K::MirrorWithFiles,
250 K::ContributionsTitle,
251 K::ContributionsLastYear,
252 K::CurrentStreak,
253 K::LongestStreak,
254 K::BestDay,
255 K::Less,
256 K::More,
257 K::MonLabel,
258 K::WedLabel,
259 K::FriLabel,
260 K::NoContributionsDay,
261 K::ViewAllNotifications,
262 K::BreadcrumbNav,
263 K::RefLabel,
264 K::YourProfile,
265 K::EditProfile,
266 K::EditOrganization,
267 K::Passed,
268 K::Failed,
269 K::Cancelled,
270 K::YourCiRuns,
271 K::SearchPublicReposFor,
272];
273
274pub fn t(lang: Lang, key: K) -> &'static str {
275 use K::*;
276 use Lang::*;
277 match (key, lang) {
278 (Appearance, En) => "Appearance",
279 (Appearance, Tr) => "Görünüm",
280 (ThemeLabel, En) => "Theme",
281 (ThemeLabel, Tr) => "Tema",
282 (LanguageLabel, En) => "Language",
283 (LanguageLabel, Tr) => "Dil",
284 (MatchSystem, En) => "Match the system",
285 (MatchSystem, Tr) => "Sistem ile eşleştir",
286 (Light, En) => "Light",
287 (Light, Tr) => "Açık",
288 (Dark, En) => "Dark",
289 (Dark, Tr) => "Koyu",
290 (MatchBrowser, En) => "Match the browser",
291 (MatchBrowser, Tr) => "Tarayıcı ile eşleştir",
292 (SwitchToLight, En) => "Switch to Light",
293 (SwitchToLight, Tr) => "Açık temaya geç",
294 (SwitchToDark, En) => "Switch to Dark",
295 (SwitchToDark, Tr) => "Koyu temaya geç",
296 (SwitchToMatchSystem, En) => "Switch to match the system",
297 (SwitchToMatchSystem, Tr) => "Sistem ile eşleştir moduna geç",
298 (ChooseTheme, En) => "Choose a theme from the list.",
299 (ChooseTheme, Tr) => "Listeden bir tema seçin.",
300 (ChooseLanguage, En) => "Choose a language from the list.",
301 (ChooseLanguage, Tr) => "Listeden bir dil seçin.",
302 (ChooseAccent, En) => "Choose an accent colour from the list.",
303 (ChooseAccent, Tr) => "Listeden bir vurgu rengi seçin.",
304 (ColoursLabel, En) => "Colours",
305 (ColoursLabel, Tr) => "Renkler",
306 (AccentRowLabel, En) => "Accent",
307 (AccentRowLabel, Tr) => "Vurgu",
308 (CustomLabel, En) => "Custom",
309 (CustomLabel, Tr) => "Özel",
310 (HueLabel, En) => "Hue",
311 (HueLabel, Tr) => "Ton",
312 (VividnessLabel, En) => "Vividness",
313 (VividnessLabel, Tr) => "Canlılık",
314 (HexLabel, En) => "Hex",
315 (HexLabel, Tr) => "Hex",
316 (BackgroundLabel, En) => "Background",
317 (BackgroundLabel, Tr) => "Arka plan",
318 (ChooseBase, En) => "Choose a background from the list.",
319 (ChooseBase, Tr) => "Listeden bir arka plan seçin.",
320 (ChooseSidebar, En) => "Choose a sidebar position from the list.",
321 (ChooseSidebar, Tr) => "Listeden bir kenar çubuğu konumu seçin.",
322 (SoundLabel, En) => "Sound",
323 (SoundLabel, Tr) => "Ses",
324 (SoundPassed, En) => "Run passed",
325 (SoundPassed, Tr) => "Çalıştırma başarılı",
326 (SoundFailed, En) => "Run failed",
327 (SoundFailed, Tr) => "Çalıştırma başarısız",
328 (ChooseSound, En) => "Choose on or off.",
329 (ChooseSound, Tr) => "Açık ya da kapalı seçin.",
330 (KindOpenIssue, En) => "Open issue",
331 (KindOpenIssue, Tr) => "Açık sorun",
332 (KindClosedIssue, En) => "Closed issue",
333 (KindClosedIssue, Tr) => "Kapalı sorun",
334 (KindOpenPull, En) => "Open pull request",
335 (KindOpenPull, Tr) => "Açık çekme isteği",
336 (KindClosedPull, En) => "Closed pull request",
337 (KindClosedPull, Tr) => "Kapalı çekme isteği",
338 (KindDiscussion, En) => "Discussion",
339 (KindDiscussion, Tr) => "Tartışma",
340 (KindSecurityAlerts, En) => "Security alerts",
341 (KindSecurityAlerts, Tr) => "Güvenlik uyarıları",
342 (KindAdminAlert, En) => "Admin alert",
343 (KindAdminAlert, Tr) => "Yönetici uyarısı",
344 (ReasonMentioned, En) => "mentioned",
345 (ReasonMentioned, Tr) => "bahsedildi",
346 (ReasonAssigned, En) => "assigned",
347 (ReasonAssigned, Tr) => "atandı",
348 (ReasonReviewRequested, En) => "review requested",
349 (ReasonReviewRequested, Tr) => "inceleme istendi",
350 (ReasonAuthor, En) => "author",
351 (ReasonAuthor, Tr) => "yazar",
352 (ReasonCommented, En) => "commented",
353 (ReasonCommented, Tr) => "yorumladı",
354 (ReasonStateChange, En) => "state change",
355 (ReasonStateChange, Tr) => "durum değişikliği",
356 (ReasonSubscribed, En) => "subscribed",
357 (ReasonSubscribed, Tr) => "abone",
358 (ReasonWatching, En) => "watching",
359 (ReasonWatching, Tr) => "izleniyor",
360 (ReasonReplied, En) => "replied",
361 (ReasonReplied, Tr) => "yanıtladı",
362 (ReasonSecurity, En) => "security",
363 (ReasonSecurity, Tr) => "güvenlik",
364 (ReasonAdmin, En) => "admin",
365 (ReasonAdmin, Tr) => "yönetici",
366 (VerbOpened, En) => "opened",
367 (VerbOpened, Tr) => "açıldı",
368 (VerbCommented, En) => "commented",
369 (VerbCommented, Tr) => "yorumlandı",
370 (VerbClosed, En) => "closed",
371 (VerbClosed, Tr) => "kapatıldı",
372 (VerbReopened, En) => "reopened",
373 (VerbReopened, Tr) => "yeniden açıldı",
374 (VerbMerged, En) => "merged",
375 (VerbMerged, Tr) => "birleştirildi",
376 (VerbReviewed, En) => "reviewed",
377 (VerbReviewed, Tr) => "incelendi",
378 (VerbReviewRequested, En) => "review requested",
379 (VerbReviewRequested, Tr) => "inceleme istendi",
380 (VerbAssigned, En) => "assigned",
381 (VerbAssigned, Tr) => "atandı",
382 (VerbMentionedYou, En) => "mentioned you",
383 (VerbMentionedYou, Tr) => "sizden bahsedildi",
384 (VerbPushedTo, En) => "pushed to",
385 (VerbPushedTo, Tr) => "gönderim yapıldı",
386 (VerbUpdated, En) => "updated",
387 (VerbUpdated, Tr) => "güncellendi",
388 (VerbDiscussionReply, En) => "commented on your discussion",
389 (VerbDiscussionReply, Tr) => "tartışmanıza yorum yapıldı",
390 (MarkAllAsRead, En) => "Mark all as read",
391 (MarkAllAsRead, Tr) => "Tümünü okundu olarak işaretle",
392 (MarkAllRead, En) => "Mark all read",
393 (MarkAllRead, Tr) => "Tümünü okundu işaretle",
394 (MarkRead, En) => "Mark read",
395 (MarkRead, Tr) => "Okundu işaretle",
396 (NoNotificationsYet, En) => "No notifications yet.",
397 (NoNotificationsYet, Tr) => "Henüz bildirim yok.",
398 (NoUnreadNotifications, En) => "No unread notifications.",
399 (NoUnreadNotifications, Tr) => "Okunmamış bildiriminiz yok.",
400 (NotificationFilter, En) => "Notification filter",
401 (NotificationFilter, Tr) => "Bildirim filtresi",
402 (Unread, En) => "Unread",
403 (Unread, Tr) => "Okunmamış",
404 (AllTab, En) => "All",
405 (AllTab, Tr) => "Tümü",
406 (Older, En) => "Older",
407 (Older, Tr) => "Daha eski",
408 (Subscribe, En) => "Subscribe",
409 (Subscribe, Tr) => "Abone ol",
410 (Unsubscribe, En) => "Unsubscribe",
411 (Unsubscribe, Tr) => "Abonelikten çık",
412 (OptParticipating, En) => "Participating",
413 (OptParticipating, Tr) => "Katılımcı",
414 (OptWatching, En) => "Watching",
415 (OptWatching, Tr) => "İzleniyor",
416 (OptIgnoring, En) => "Ignoring",
417 (OptIgnoring, Tr) => "Yok sayılıyor",
418 (SecurityOff, En) => {
419 "Security advisories are off on this instance, so no lockfile is scanned. An administrator can turn them on with the [advisories] section of the config."
420 }
421 (SecurityOff, Tr) => {
422 "Bu sunucuda güvenlik tavsiyeleri kapalı, bu yüzden hiçbir kilit dosyası taranmıyor. Bir yönetici bunları yapılandırma dosyasındaki [advisories] bölümünden açabilir."
423 }
424 (NoAlerts, En) => "No alerts.",
425 (NoAlerts, Tr) => "Uyarı yok.",
426 (StateOpen, En) => "Open",
427 (StateOpen, Tr) => "Açık",
428 (StateDismissed, En) => "Dismissed",
429 (StateDismissed, Tr) => "Yoksayıldı",
430 (StateFixed, En) => "Fixed",
431 (StateFixed, Tr) => "Düzeltildi",
432 (Dismiss, En) => "Dismiss",
433 (Dismiss, Tr) => "Yoksay",
434 (Reopen, En) => "Reopen",
435 (Reopen, Tr) => "Yeniden aç",
436 (NewOwner, En) => "Owner",
437 (NewOwner, Tr) => "Sahip",
438 (RepoName, En) => "Repository name",
439 (RepoName, Tr) => "Depo adı",
440 (DescriptionOptional, En) => "Description (optional)",
441 (DescriptionOptional, Tr) => "Açıklama (isteğe bağlı)",
442 (VisibilityLegend, En) => "Visibility",
443 (VisibilityLegend, Tr) => "Görünürlük",
444 (DefaultBranch, En) => "Default branch",
445 (DefaultBranch, Tr) => "Varsayılan dal",
446 (AddDefaultLabels, En) => {
447 "Add default labels (bug, documentation, enhancement and the rest)"
448 }
449 (AddDefaultLabels, Tr) => {
450 "Varsayılan etiketleri ekle (bug, documentation, enhancement ve diğerleri)"
451 }
452 (MirrorLegend, En) => "Mirror an existing repository (optional)",
453 (MirrorLegend, Tr) => "Mevcut bir depoyu yansıt (isteğe bağlı)",
454 (SourceUrl, En) => "Source URL",
455 (SourceUrl, Tr) => "Kaynak URL",
456 (UsernameOptional, En) => "Username (optional)",
457 (UsernameOptional, Tr) => "Kullanıcı adı (isteğe bağlı)",
458 (PasswordOrToken, En) => "Password or token (optional)",
459 (PasswordOrToken, Tr) => "Parola veya belirteç (isteğe bağlı)",
460 (SyncInterval, En) => "Sync interval in minutes (0 = manual only, at least 10)",
461 (SyncInterval, Tr) => "Eşitleme aralığı (dakika; 0 = yalnızca elle, en az 10)",
462 (CreateRepository, En) => "Create repository",
463 (CreateRepository, Tr) => "Depo oluştur",
464 (OwnerRefused, En) => "you cannot create repositories for that owner",
465 (OwnerRefused, Tr) => "bu sahip için depo oluşturamazsınız",
466 (InvalidRepoName, En) => "invalid repository name",
467 (InvalidRepoName, Tr) => "geçersiz depo adı",
468 (ReadmeLabel, En) => "Add a README",
469 (ReadmeLabel, Tr) => "README ekle",
470 (LicenseLabel, En) => "License",
471 (LicenseLabel, Tr) => "Lisans",
472 (LicenseNone, En) => "None",
473 (LicenseNone, Tr) => "Yok",
474 (UnknownLicense, En) => "unknown license",
475 (UnknownLicense, Tr) => "Bilinmeyen lisans.",
476 (MirrorWithFiles, En) => {
477 "A mirror fills the repository from its source; leave README and license off."
478 }
479 (MirrorWithFiles, Tr) => {
480 "Yansı, depoyu kaynağından doldurur; README ve lisansı kapalı bırakın."
481 }
482 (ContributionsTitle, En) => "Contributions",
483 (ContributionsTitle, Tr) => "Katkılar",
484 (ContributionsLastYear, En) => "contributions in the last year",
485 (ContributionsLastYear, Tr) => "son bir yılda katkı",
486 (CurrentStreak, En) => "Current streak",
487 (CurrentStreak, Tr) => "Mevcut seri",
488 (LongestStreak, En) => "Longest streak",
489 (LongestStreak, Tr) => "En uzun seri",
490 (BestDay, En) => "Best day",
491 (BestDay, Tr) => "En iyi gün",
492 (Less, En) => "Less",
493 (Less, Tr) => "Az",
494 (More, En) => "More",
495 (More, Tr) => "Çok",
496 (MonLabel, En) => "Mon",
497 (MonLabel, Tr) => "Pzt",
498 (WedLabel, En) => "Wed",
499 (WedLabel, Tr) => "Çar",
500 (FriLabel, En) => "Fri",
501 (FriLabel, Tr) => "Cum",
502 (NoContributionsDay, En) => "No contributions on this day.",
503 (NoContributionsDay, Tr) => "Bu günde katkı yok.",
504 (ViewAllNotifications, En) => "View all notifications",
505 (ViewAllNotifications, Tr) => "Tüm bildirimleri gör",
506 (BreadcrumbNav, En) => "Path",
507 (BreadcrumbNav, Tr) => "Yol",
508 (RefLabel, En) => "Ref",
509 (RefLabel, Tr) => "Referans",
510 (YourProfile, En) => "Your profile",
511 (YourProfile, Tr) => "Profilin",
512 (EditProfile, En) => "Edit profile",
513 (EditProfile, Tr) => "Profili düzenle",
514 (EditOrganization, En) => "Edit organization",
515 (EditOrganization, Tr) => "Kuruluşu düzenle",
516 (Passed, En) => "passed",
517 (Passed, Tr) => "geçti",
518 (Failed, En) => "failed",
519 (Failed, Tr) => "başarısız",
520 (Cancelled, En) => "cancelled",
521 (Cancelled, Tr) => "iptal edildi",
522 (YourCiRuns, En) => "Your CI runs",
523 (YourCiRuns, Tr) => "CI çalıştırmaların",
524 (SearchPublicReposFor, En) => "Search public repositories for",
525 (SearchPublicReposFor, Tr) => "Herkese açık depolarda ara:",
526 }
527}
528
529/// `1,284` in English, `1.284` in Turkish.
530pub fn thousands(lang: Lang, n: u64) -> String {
531 let sep = match lang {
532 Lang::En => ',',
533 Lang::Tr => '.',
534 };
535 let digits = n.to_string();
536 let mut out = String::with_capacity(digits.len() + digits.len() / 3);
537 for (i, ch) in digits.chars().enumerate() {
538 if i > 0 && (digits.len() - i).is_multiple_of(3) {
539 out.push(sep);
540 }
541 out.push(ch);
542 }
543 out
544}
545
546/// `12 days` / `12 gün`, for a streak length.
547pub fn streak_days(lang: Lang, n: u64) -> String {
548 match lang {
549 Lang::En => format!("{n} day{}", if n == 1 { "" } else { "s" }),
550 Lang::Tr => format!("{n} gün"),
551 }
552}
553
554/// `28 running` / `3 çalışıyor`: the live strip's counts. Each takes its number as `{n}` in the
555/// strip's templates, so these phrases have no plural.
556pub fn running_count(lang: Lang, n: u64) -> String {
557 match lang {
558 Lang::En => format!("{n} running"),
559 Lang::Tr => format!("{n} çalışıyor"),
560 }
561}
562
563/// `2 failed` / `2 başarısız`.
564pub fn failed_count(lang: Lang, n: u64) -> String {
565 match lang {
566 Lang::En => format!("{n} failed"),
567 Lang::Tr => format!("{n} başarısız"),
568 }
569}
570
571/// `2 passed` / `2 başarılı`.
572pub fn passed_count(lang: Lang, n: u64) -> String {
573 match lang {
574 Lang::En => format!("{n} passed"),
575 Lang::Tr => format!("{n} başarılı"),
576 }
577}
578
579/// `2 cancelled` / `2 iptal edildi`.
580pub fn cancelled_count(lang: Lang, n: u64) -> String {
581 match lang {
582 Lang::En => format!("{n} cancelled"),
583 Lang::Tr => format!("{n} iptal edildi"),
584 }
585}
586
587/// `1 contribution` / `3 contributions`, and `3 katkı` in Turkish.
588pub fn contributions_count(lang: Lang, n: u64) -> String {
589 match lang {
590 Lang::En => format!("{n} contribution{}", if n == 1 { "" } else { "s" }),
591 Lang::Tr => format!("{n} katkı"),
592 }
593}
594
595/// Short month name, `1..=12`. Turkish uses the usual three-letter forms.
596pub fn month_abbrev(lang: Lang, month: i64) -> &'static str {
597 const EN: [&str; 12] = [
598 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
599 ];
600 const TR: [&str; 12] = [
601 "Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara",
602 ];
603 let index = (month.clamp(1, 12) - 1) as usize;
604 match lang {
605 Lang::En => EN[index],
606 Lang::Tr => TR[index],
607 }
608}
609
610/// `16 Oct 2026` in English, `16 Eki 2026` in Turkish.
611pub fn date_text(lang: Lang, year: i64, month: i64, day: i64) -> String {
612 format!("{day} {} {year}", month_abbrev(lang, month))
613}
614
615/// `16 Oct 2025 to 16 Oct 2026` in English; Turkish uses `ile ... arası`.
616pub fn date_range(lang: Lang, from: &str, to: &str) -> String {
617 match lang {
618 Lang::En => format!("{from} to {to}"),
619 Lang::Tr => format!("{from} ile {to} arası"),
620 }
621}
622
623/// The calendar's accessible summary, for the grid's `aria-label`.
624pub fn heatmap_summary(lang: Lang, total: u64, current: u64, longest: u64) -> String {
625 let total = thousands(lang, total);
626 let current = streak_days(lang, current);
627 let longest = streak_days(lang, longest);
628 match lang {
629 Lang::En => format!(
630 "Contribution calendar: {total} contributions in the last year. Current streak {current}, longest streak {longest}."
631 ),
632 Lang::Tr => format!(
633 "Katkı takvimi: son bir yılda {total} katkı. Mevcut seri {current}, en uzun seri {longest}."
634 ),
635 }
636}
637
638/// A calendar cell's hover text: `3 contributions on 16 Oct 2026`.
639pub fn contributions_on(lang: Lang, n: u64, date: &str) -> String {
640 match lang {
641 Lang::En => format!("{} on {date}", contributions_count(lang, n)),
642 Lang::Tr => format!("{date}: {}", contributions_count(lang, n)),
643 }
644}
645
646/// The heading above a selected calendar day's contributions, e.g. `Contributions on 16 Oct 2026`.
647pub fn contributions_on_day(lang: Lang, date: &str) -> String {
648 match lang {
649 Lang::En => format!("Contributions on {date}"),
650 Lang::Tr => format!("{date} tarihindeki katkılar"),
651 }
652}
653
654/// The words either side of a day item's link. The link is the repo for a push and `#N title`
655/// otherwise, so `repo` (`owner/repo`) goes in the words only where the link is not the repo.
656pub fn day_item_words(
657 lang: Lang,
658 kind: ContributionKind,
659 branch: &str,
660 repo: &str,
661) -> (String, String) {
662 match (lang, kind) {
663 (Lang::En, ContributionKind::Push) => (format!("Pushed to {branch} in"), String::new()),
664 (Lang::En, ContributionKind::Issue) => ("Opened issue".to_owned(), format!("in {repo}")),
665 (Lang::En, ContributionKind::Pull) => {
666 ("Opened pull request".to_owned(), format!("in {repo}"))
667 }
668 (Lang::En, ContributionKind::Comment) => ("Commented on".to_owned(), format!("in {repo}")),
669 (Lang::En, ContributionKind::CoAuthored) => {
670 (format!("Co-authored a commit in {repo}:"), String::new())
671 }
672 (Lang::Tr, ContributionKind::Push) => {
673 (String::new(), format!("deposunda {branch} dalına gönderim"))
674 }
675 (Lang::Tr, ContributionKind::Issue) => {
676 (String::new(), format!("sorunu {repo} deposunda açtı"))
677 }
678 (Lang::Tr, ContributionKind::Pull) => (
679 String::new(),
680 format!("çekme isteğini {repo} deposunda açtı"),
681 ),
682 (Lang::Tr, ContributionKind::Comment) => (
683 String::new(),
684 format!("konusuna {repo} deposunda yorum yaptı"),
685 ),
686 (Lang::Tr, ContributionKind::CoAuthored) => (
687 String::new(),
688 format!("commit'ine {repo} deposunda ortak yazar oldu"),
689 ),
690 }
691}
692
693/// The words either side of a grouped row for `count` pushes to one branch, e.g. `Pushed 7 times to
694/// main in` with the repo as the link. The link is the repo, as for a single push.
695pub fn push_group_words(lang: Lang, branch: &str, count: usize) -> (String, String) {
696 match lang {
697 Lang::En => (
698 format!("Pushed {count} times to {branch} in"),
699 String::new(),
700 ),
701 Lang::Tr => (
702 String::new(),
703 format!("deposunda {branch} dalına {count} gönderim"),
704 ),
705 }
706}
707
708/// The words either side of a grouped row for `count` pushes across `branches` branches of one
709/// repo, e.g. `Pushed 9 times to 6 branches in` with the repo as the link.
710pub fn push_repo_group_words(lang: Lang, branches: usize, count: usize) -> (String, String) {
711 match lang {
712 Lang::En => (
713 format!("Pushed {count} times to {branches} branches in"),
714 String::new(),
715 ),
716 Lang::Tr => (
717 String::new(),
718 format!("deposunda {branches} dala {count} gönderim"),
719 ),
720 }
721}
722
723/// The activity line for an inbox row: the verb, then the actor when there is one. English reads
724/// "opened by tahinli"; Turkish reads "tahinli tarafından açıldı", or "Açıldı" with no actor.
725pub fn activity_line(lang: Lang, verb: K, actor: Option<&str>) -> String {
726 let verb = t(lang, verb);
727 match (lang, actor) {
728 (Lang::En, Some(actor)) => format!("{verb} by {actor}"),
729 (Lang::En, None) => verb.to_owned(),
730 (Lang::Tr, Some(actor)) => format!("{actor} tarafından {verb}"),
731 (Lang::Tr, None) => capitalize(verb),
732 }
733}
734
735/// "3 watching" / "3 izleyici", the watch control's count.
736pub fn watchers_count(lang: Lang, watchers: u64) -> String {
737 match lang {
738 Lang::En => format!("{watchers} watching"),
739 Lang::Tr => format!("{watchers} izleyici"),
740 }
741}
742
743/// "3 new alerts" / "3 yeni uyarı".
744pub fn new_alerts(lang: Lang, count: u64) -> String {
745 match lang {
746 Lang::En if count == 1 => format!("{count} new alert"),
747 Lang::En => format!("{count} new alerts"),
748 Lang::Tr => format!("{count} yeni uyarı"),
749 }
750}
751
752/// The security page's summary of how many dependencies were read and how many alerts are open.
753pub fn dependencies_summary(lang: Lang, dependencies: u64, open: usize) -> String {
754 match lang {
755 Lang::En => format!(
756 "{dependencies} dependencies were read from the lockfiles on the default branch. {open} open alerts."
757 ),
758 Lang::Tr => format!(
759 "Varsayılan daldaki kilit dosyalarından {dependencies} bağımlılık okundu. {open} açık uyarı var."
760 ),
761 }
762}
763
764/// The new-repo error for a description over the limit.
765pub fn description_too_long(lang: Lang, max: usize) -> String {
766 match lang {
767 Lang::En => format!("description must be at most {max} characters"),
768 Lang::Tr => format!("açıklama en fazla {max} karakter olabilir"),
769 }
770}
771
772/// The new-repo error when the git repository could not be created.
773pub fn git_init_failed(lang: Lang, error: impl Display) -> String {
774 match lang {
775 Lang::En => format!("could not create the git repository: {error}"),
776 Lang::Tr => format!("git deposu oluşturulamadı: {error}"),
777 }
778}
779
780/// Upper-cases the first character. Turkish verbs here start with a plain letter, so the
781/// default mapping is right.
782fn capitalize(text: &str) -> String {
783 let mut chars = text.chars();
784 match chars.next() {
785 Some(first) => first.to_uppercase().chain(chars).collect(),
786 None => String::new(),
787 }
788}
789
790#[cfg(test)]
791mod tests {
792 use super::*;
793
794 #[test]
795 fn every_variant_has_both_languages() {
796 for key in ALL {
797 assert!(!t(Lang::En, *key).is_empty(), "{key:?} has no English");
798 assert!(!t(Lang::Tr, *key).is_empty(), "{key:?} has no Turkish");
799 }
800 }
801
802 #[test]
803 fn turkish_differs_from_english_for_translated_phrases() {
804 let differing = ALL
805 .iter()
806 .filter(|key| t(Lang::En, **key) != t(Lang::Tr, **key))
807 .count();
808 assert!(differing >= 3, "only {differing} phrases are translated");
809 assert_eq!(t(Lang::Tr, K::Appearance), "Görünüm");
810 }
811
812 #[test]
813 fn activity_lines_keep_the_english_wording() {
814 assert_eq!(
815 activity_line(Lang::En, K::VerbOpened, Some("tahinli")),
816 "opened by tahinli"
817 );
818 assert_eq!(activity_line(Lang::En, K::VerbUpdated, None), "updated");
819 assert_eq!(
820 activity_line(Lang::Tr, K::VerbOpened, Some("tahinli")),
821 "tahinli tarafından açıldı"
822 );
823 assert_eq!(activity_line(Lang::Tr, K::VerbUpdated, None), "Güncellendi");
824 assert_eq!(
825 activity_line(Lang::En, K::VerbReviewRequested, Some("tahinli")),
826 "review requested by tahinli"
827 );
828 assert_eq!(
829 activity_line(Lang::Tr, K::VerbReviewRequested, Some("tahinli")),
830 "tahinli tarafından inceleme istendi"
831 );
832 }
833
834 #[test]
835 fn plural_helpers_match_english() {
836 assert_eq!(new_alerts(Lang::En, 1), "1 new alert");
837 assert_eq!(new_alerts(Lang::En, 2), "2 new alerts");
838 assert_eq!(new_alerts(Lang::Tr, 3), "3 yeni uyarı");
839 }
840}