|
| 1 | +--- |
| 2 | +interface Props { |
| 3 | + englishUrl?: string; |
| 4 | + contributeUrl?: string; |
| 5 | + title?: string; |
| 6 | + message?: string; |
| 7 | + locale?: string; |
| 8 | +} |
| 9 | +
|
| 10 | +const { |
| 11 | + englishUrl = '/en', |
| 12 | + contributeUrl = 'https://github.com/processing/p5.js-website/tree/main?tab=readme-ov-file#content-changes', |
| 13 | + title, |
| 14 | + message, |
| 15 | + locale = 'en', |
| 16 | +} = Astro.props as Props; |
| 17 | +
|
| 18 | +const copyByLocale: Record<string, { title: string; message: string; viewEnglish: string; contribute: string; }> = { |
| 19 | + 'hi': { |
| 20 | + title: 'यह अनुवाद पुराना हो सकता है', |
| 21 | + message: 'यह पृष्ठ अंग्रेज़ी संस्करण की तुलना में अद्यतन नहीं है।', |
| 22 | + viewEnglish: 'अंग्रेज़ी संस्करण देखें', |
| 23 | + contribute: 'अनुवाद में योगदान दें', |
| 24 | + }, |
| 25 | + 'es': { |
| 26 | + title: 'Esta traducción podría estar desactualizada', |
| 27 | + message: 'Esta página no está actualizada en comparación con la versión en inglés.', |
| 28 | + viewEnglish: 'Ver versión en inglés', |
| 29 | + contribute: 'Contribuir a la traducción', |
| 30 | + }, |
| 31 | + 'ko': { |
| 32 | + title: '이 번역은 오래되었을 수 있습니다', |
| 33 | + message: '이 페이지는 영어 버전과 비교하여 최신 상태가 아닙니다.', |
| 34 | + viewEnglish: '영어 페이지 보기', |
| 35 | + contribute: '번역에 기여하기', |
| 36 | + }, |
| 37 | + 'zh-Hans': { |
| 38 | + title: '此翻译可能已过期', |
| 39 | + message: '与英文版本相比,此页面不是最新的。', |
| 40 | + viewEnglish: '查看英文页面', |
| 41 | + contribute: '参与翻译', |
| 42 | + }, |
| 43 | +}; |
| 44 | +
|
| 45 | +const fallback = { |
| 46 | + title: 'This translation might be outdated', |
| 47 | + message: 'This page is not updated compared to the English version.', |
| 48 | + viewEnglish: 'View English page', |
| 49 | + contribute: 'Contribute to translation', |
| 50 | +}; |
| 51 | +
|
| 52 | +const copy = copyByLocale[locale] || fallback; |
| 53 | +const resolvedTitle = title ?? copy.title; |
| 54 | +const resolvedMessage = message ?? copy.message; |
| 55 | +--- |
| 56 | + |
| 57 | +<section class="outdated-banner" role="status" aria-live="polite"> |
| 58 | + <div class="icon" aria-hidden="true">⚠️</div> |
| 59 | + <div class="content"> |
| 60 | + <div class="title">{resolvedTitle}</div> |
| 61 | + <p class="desc"> |
| 62 | + {resolvedMessage} |
| 63 | + <a class="link" href={englishUrl}>{copy.viewEnglish}</a> |
| 64 | + · |
| 65 | + <a class="link" href={contributeUrl} target="_blank" rel="noopener noreferrer">{copy.contribute}</a> |
| 66 | + </p> |
| 67 | + </div> |
| 68 | + |
| 69 | + <style> |
| 70 | + .outdated-banner { |
| 71 | + display: flex; |
| 72 | + align-items: flex-start; |
| 73 | + gap: 16px; |
| 74 | + padding: 16px 20px; |
| 75 | + border-radius: 12px; |
| 76 | + background: #d8f532; |
| 77 | + color: #000; |
| 78 | + margin: 16px 0 24px; |
| 79 | + } |
| 80 | + .icon { font-size: 22px; line-height: 1; margin-top: 2px; } |
| 81 | + .content { flex: 1; } |
| 82 | + .title { font-weight: 700; font-size: 16px; margin-bottom: 6px; } |
| 83 | + .desc { margin: 0; font-size: 14px; } |
| 84 | + .link { color: inherit; font-weight: 700; text-underline-offset: 2px; } |
| 85 | + .link:hover { text-decoration: underline; } |
| 86 | + </style> |
| 87 | +</section> |
| 88 | + |
0 commit comments