|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +const EN_SITE_URL = 'https://fullstackopen.com/en/'; |
| 4 | + |
| 5 | +const MORE_INFO_URL_BY_LANGUAGE = { |
| 6 | + fi: '/new-platform/', |
| 7 | + en: '/en/new-platform/', |
| 8 | + zh: '/zh/new-platform/', |
| 9 | + es: '/es/new-platform/', |
| 10 | + fr: '/fr/new-platform/', |
| 11 | + ptbr: '/ptbr/new-platform/', |
| 12 | +}; |
| 13 | + |
| 14 | +const TEXT_BY_LANGUAGE = { |
| 15 | + en: { |
| 16 | + ariaLabel: 'New platform notice', |
| 17 | + closeAriaLabel: 'Close notice', |
| 18 | + machineTranslatedNote: null, |
| 19 | + p1: 'Starting from Part 6 onward, Full Stack Open has moved to a new platform. This site is no longer being updated, and any exercises you submit here for Part 6 and later will not be counted.', |
| 20 | + p2Pre: 'Please see the ', |
| 21 | + siteLinkText: 'English version of the Full Stack Open page', |
| 22 | + p2Mid: |
| 23 | + ' for the links to the new platform parts, and continue your studies there. For more information click ', |
| 24 | + hereLinkText: 'here', |
| 25 | + p2End: '.', |
| 26 | + p3: 'Unfortunately, the new platform is currently available only in English. There is ongoing work to see if language support can be brought back in the future.', |
| 27 | + }, |
| 28 | + fi: { |
| 29 | + ariaLabel: 'Ilmoitus uudesta alustasta', |
| 30 | + closeAriaLabel: 'Sulje ilmoitus', |
| 31 | + machineTranslatedNote: 'Konekäännetty suomeksi.', |
| 32 | + p1: 'Osasta 6 alkaen Full Stack Open on siirtynyt uudelle alustalle. Tätä sivustoa ei enää päivitetä, eikä osan 6 ja sitä myöhempien osien tehtäviä lasketa, jos ne palautetaan täällä.', |
| 33 | + p2Pre: 'Katso ', |
| 34 | + siteLinkText: 'Full Stack Open -sivuston englanninkielisestä versiosta', |
| 35 | + p2Mid: |
| 36 | + ' linkit uuden alustan osiin ja jatka opintojasi siellä. Lisätietoa saat ', |
| 37 | + hereLinkText: 'täältä', |
| 38 | + p2End: '.', |
| 39 | + p3: 'Valitettavasti uusi alusta on toistaiseksi saatavilla vain englanniksi. Kielten tuen palauttamista muille kielille selvitetään parhaillaan.', |
| 40 | + }, |
| 41 | + zh: { |
| 42 | + ariaLabel: '新平台通知', |
| 43 | + closeAriaLabel: '关闭通知', |
| 44 | + machineTranslatedNote: '本内容为机器翻译。', |
| 45 | + p1: '从第 6 部分开始,全栈公开课已迁移到新平台。本网站将不再更新,您在此提交的第 6 部分及以后的练习将不计入成绩。', |
| 46 | + p2Pre: '请查看 ', |
| 47 | + siteLinkText: '全栈公开课页面的英文版本', |
| 48 | + p2Mid: ',获取新平台各部分的链接,并在那里继续学习。欲了解更多信息,请点击', |
| 49 | + hereLinkText: '此处', |
| 50 | + p2End: '。', |
| 51 | + p3: '很遗憾,新平台目前仅提供英文版本。我们正在努力研究未来是否能够恢复对其他语言的支持。', |
| 52 | + }, |
| 53 | + es: { |
| 54 | + ariaLabel: 'Aviso sobre la nueva plataforma', |
| 55 | + closeAriaLabel: 'Cerrar aviso', |
| 56 | + machineTranslatedNote: null, |
| 57 | + p1: 'A partir de la Parte 6 en adelante, Full Stack Open se ha trasladado a una nueva plataforma. Este sitio ya no se actualiza, y cualquier ejercicio que envíes aquí para la Parte 6 o posterior no será contabilizado.', |
| 58 | + p2Pre: 'Consulta la ', |
| 59 | + siteLinkText: 'versión en inglés de la página de Full Stack Open', |
| 60 | + p2Mid: |
| 61 | + ' para encontrar los enlaces a las nuevas partes de la plataforma y continúa tus estudios allí. Para más información, haz clic ', |
| 62 | + hereLinkText: 'aquí', |
| 63 | + p2End: '.', |
| 64 | + p3: 'Desafortunadamente, la nueva plataforma actualmente solo está disponible en inglés. Se está trabajando para ver si el soporte de idiomas puede volver en el futuro.', |
| 65 | + }, |
| 66 | + fr: { |
| 67 | + ariaLabel: 'Avis concernant la nouvelle plateforme', |
| 68 | + closeAriaLabel: "Fermer l'avis", |
| 69 | + machineTranslatedNote: 'Traduction automatique en français.', |
| 70 | + p1: "À partir de la partie 6, Full Stack Open a été déplacé vers une nouvelle plateforme. Ce site n'est plus mis à jour, et les exercices que vous soumettez ici pour la partie 6 et au-delà ne seront pas comptabilisés.", |
| 71 | + p2Pre: 'Veuillez consulter la ', |
| 72 | + siteLinkText: 'version anglaise de la page Full Stack Open', |
| 73 | + p2Mid: |
| 74 | + " pour obtenir les liens vers les parties de la nouvelle plateforme, et poursuivre vos études là-bas. Pour plus d'informations, cliquez ", |
| 75 | + hereLinkText: 'ici', |
| 76 | + p2End: '.', |
| 77 | + p3: "Malheureusement, la nouvelle plateforme n'est actuellement disponible qu'en anglais. Des travaux sont en cours pour voir si la prise en charge d'autres langues pourra être rétablie à l'avenir.", |
| 78 | + }, |
| 79 | + ptbr: { |
| 80 | + ariaLabel: 'Aviso sobre a nova plataforma', |
| 81 | + closeAriaLabel: 'Fechar aviso', |
| 82 | + machineTranslatedNote: 'Traduzido automaticamente para o português (BR).', |
| 83 | + p1: 'A partir da Parte 6, o Full Stack Open foi migrado para uma nova plataforma. Este site não está mais sendo atualizado, e os exercícios enviados aqui para a Parte 6 em diante não serão contabilizados.', |
| 84 | + p2Pre: 'Consulte a ', |
| 85 | + siteLinkText: 'versão em inglês da página do Full Stack Open', |
| 86 | + p2Mid: |
| 87 | + ' para ver os links das partes na nova plataforma e continuar seus estudos por lá. Para mais informações, clique ', |
| 88 | + hereLinkText: 'aqui', |
| 89 | + p2End: '.', |
| 90 | + p3: 'Infelizmente, a nova plataforma está disponível apenas em inglês por enquanto. Há um trabalho em andamento para verificar se o suporte a outros idiomas poderá ser reintroduzido no futuro.', |
| 91 | + }, |
| 92 | +}; |
| 93 | + |
| 94 | +const InfoBannerNewPlatform = ({ visible, onHide, language }) => { |
| 95 | + // English and Finnish content is up to date on this site, so this |
| 96 | + // notice is only relevant for the other languages. |
| 97 | + if (!visible || language === 'en' || language === 'fi') return null; |
| 98 | + |
| 99 | + const content = TEXT_BY_LANGUAGE[language] || TEXT_BY_LANGUAGE.en; |
| 100 | + const { |
| 101 | + ariaLabel, |
| 102 | + closeAriaLabel, |
| 103 | + machineTranslatedNote, |
| 104 | + p1, |
| 105 | + p2Pre, |
| 106 | + siteLinkText, |
| 107 | + p2Mid, |
| 108 | + hereLinkText, |
| 109 | + p2End, |
| 110 | + p3, |
| 111 | + } = content; |
| 112 | + |
| 113 | + const moreInfoUrl = |
| 114 | + MORE_INFO_URL_BY_LANGUAGE[language] || MORE_INFO_URL_BY_LANGUAGE.en; |
| 115 | + |
| 116 | + const style = { |
| 117 | + position: 'fixed', |
| 118 | + left: 24, |
| 119 | + right: 24, |
| 120 | + bottom: 20, |
| 121 | + display: 'flex', |
| 122 | + alignItems: 'flex-start', |
| 123 | + gap: 16, |
| 124 | + padding: 14, |
| 125 | + borderStyle: 'solid', |
| 126 | + borderWidth: 2, |
| 127 | + borderColor: '#ffc107', |
| 128 | + backgroundColor: '#fff3cd', |
| 129 | + color: '#5a4000', |
| 130 | + zIndex: 2147483647, |
| 131 | + boxShadow: '0 8px 30px rgba(0, 0, 0, 0.2)', |
| 132 | + }; |
| 133 | + |
| 134 | + const textStyle = { |
| 135 | + flex: 1, |
| 136 | + minWidth: 0, |
| 137 | + lineHeight: '1.4em', |
| 138 | + }; |
| 139 | + |
| 140 | + const noteStyle = { |
| 141 | + marginBottom: 8, |
| 142 | + fontStyle: 'italic', |
| 143 | + fontSize: '0.85em', |
| 144 | + color: '#5a4000', |
| 145 | + }; |
| 146 | + |
| 147 | + const paragraphStyle = { |
| 148 | + marginBottom: 8, |
| 149 | + color: '#000', |
| 150 | + }; |
| 151 | + |
| 152 | + const linkStyle = { |
| 153 | + color: '#5a4000', |
| 154 | + fontWeight: 600, |
| 155 | + textDecoration: 'underline', |
| 156 | + }; |
| 157 | + |
| 158 | + const buttonStyle = { |
| 159 | + outline: 'none', |
| 160 | + backgroundColor: 'transparent', |
| 161 | + border: 'none', |
| 162 | + color: '#5a4000', |
| 163 | + cursor: 'pointer', |
| 164 | + fontSize: 18, |
| 165 | + lineHeight: 1, |
| 166 | + }; |
| 167 | + |
| 168 | + return ( |
| 169 | + <div style={style} role="region" aria-label={ariaLabel}> |
| 170 | + <div style={textStyle}> |
| 171 | + {machineTranslatedNote && <p style={noteStyle}>{machineTranslatedNote}</p>} |
| 172 | + |
| 173 | + <p style={paragraphStyle}>{p1}</p> |
| 174 | + |
| 175 | + <p style={paragraphStyle}> |
| 176 | + {p2Pre} |
| 177 | + <a style={linkStyle} href={EN_SITE_URL}> |
| 178 | + {siteLinkText} |
| 179 | + </a> |
| 180 | + {p2Mid} |
| 181 | + <a style={linkStyle} href={moreInfoUrl}> |
| 182 | + {hereLinkText} |
| 183 | + </a> |
| 184 | + {p2End} |
| 185 | + </p> |
| 186 | + |
| 187 | + <p style={{ ...paragraphStyle, marginBottom: 0 }}>{p3}</p> |
| 188 | + </div> |
| 189 | + <button |
| 190 | + style={buttonStyle} |
| 191 | + onClick={onHide} |
| 192 | + aria-label={closeAriaLabel} |
| 193 | + > |
| 194 | + x |
| 195 | + </button> |
| 196 | + </div> |
| 197 | + ); |
| 198 | +}; |
| 199 | + |
| 200 | +export default InfoBannerNewPlatform; |
0 commit comments