feat(i18n): url validation translations (#41190)
This commit is contained in:
@ -474,7 +474,10 @@
|
|||||||
"invalid-url": "我们无法验证你的 URL,请确保填写正确",
|
"invalid-url": "我们无法验证你的 URL,请确保填写正确",
|
||||||
"invalid-protocol": "URL 必须以 http 或 https 开头",
|
"invalid-protocol": "URL 必须以 http 或 https 开头",
|
||||||
"url-not-image": "URL 必须直接链接到图片文件",
|
"url-not-image": "URL 必须直接链接到图片文件",
|
||||||
"use-valid-url": "请使用有效的 URL"
|
"use-valid-url": "请使用有效的 URL",
|
||||||
|
"editor-url": "Remember to submit the Live App URL.",
|
||||||
|
"own-work-url": "Remember to submit your own work.",
|
||||||
|
"publicly-visible-url": "Remember to submit a publicly visible app URL."
|
||||||
},
|
},
|
||||||
"certification": {
|
"certification": {
|
||||||
"executive": "执行董事,freeCodeCamp.org",
|
"executive": "执行董事,freeCodeCamp.org",
|
||||||
|
@ -474,7 +474,10 @@
|
|||||||
"invalid-url": "We could not validate your URL correctly, please ensure it is correct",
|
"invalid-url": "We could not validate your URL correctly, please ensure it is correct",
|
||||||
"invalid-protocol": "URL must start with http or https",
|
"invalid-protocol": "URL must start with http or https",
|
||||||
"url-not-image": "URL must link directly to an image file",
|
"url-not-image": "URL must link directly to an image file",
|
||||||
"use-valid-url": "Please use a valid URL"
|
"use-valid-url": "Please use a valid URL",
|
||||||
|
"editor-url": "Remember to submit the Live App URL.",
|
||||||
|
"own-work-url": "Remember to submit your own work.",
|
||||||
|
"publicly-visible-url": "Remember to submit a publicly visible app URL."
|
||||||
},
|
},
|
||||||
"certification": {
|
"certification": {
|
||||||
"executive": "Executive Director, freeCodeCamp.org",
|
"executive": "Executive Director, freeCodeCamp.org",
|
||||||
|
@ -474,7 +474,10 @@
|
|||||||
"invalid-url": "No hemos podido validar tu URL correctamente, por favor asegúrate de que sea correcta",
|
"invalid-url": "No hemos podido validar tu URL correctamente, por favor asegúrate de que sea correcta",
|
||||||
"invalid-protocol": "La URL debe comenzar con http o https",
|
"invalid-protocol": "La URL debe comenzar con http o https",
|
||||||
"url-not-image": "La URL debe enlazar directamente hacia un archivo de imagen",
|
"url-not-image": "La URL debe enlazar directamente hacia un archivo de imagen",
|
||||||
"use-valid-url": "Por favor, utiliza una URL válida"
|
"use-valid-url": "Por favor, utiliza una URL válida",
|
||||||
|
"editor-url": "Remember to submit the Live App URL.",
|
||||||
|
"own-work-url": "Remember to submit your own work.",
|
||||||
|
"publicly-visible-url": "Remember to submit a publicly visible app URL."
|
||||||
},
|
},
|
||||||
"certification": {
|
"certification": {
|
||||||
"executive": "Director Ejecutivo, freeCodeCamp.org",
|
"executive": "Director Ejecutivo, freeCodeCamp.org",
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Trans } from 'react-i18next';
|
||||||
|
|
||||||
// Matches editor links for: Repl.it, Glitch, CodeSandbox, GitHub
|
// Matches editor links for: Repl.it, Glitch, CodeSandbox, GitHub
|
||||||
const editorRegex = /repl\.it\/(@|join\/)|glitch\.com\/edit\/#!|codesandbox\.io\/s\/|github\.com/;
|
const editorRegex = /repl\.it\/(@|join\/)|glitch\.com\/edit\/#!|codesandbox\.io\/s\/|github\.com/;
|
||||||
const fCCRegex = /codepen\.io\/freecodecamp|freecodecamp\.rocks|github\.com\/freecodecamp/i;
|
const fCCRegex = /codepen\.io\/freecodecamp|freecodecamp\.rocks|github\.com\/freecodecamp/i;
|
||||||
const localhostRegex = /localhost:/;
|
const localhostRegex = /localhost:/;
|
||||||
|
|
||||||
export const editorValidator = value =>
|
export const editorValidator = value =>
|
||||||
editorRegex.test(value) ? 'Remember to submit the Live App URL.' : null;
|
editorRegex.test(value) ? <Trans>validation.editor-url</Trans> : null;
|
||||||
|
|
||||||
export const fCCValidator = value =>
|
export const fCCValidator = value =>
|
||||||
fCCRegex.test(value) ? 'Remember to submit your own work.' : null;
|
fCCRegex.test(value) ? <Trans>validation.own-work-url</Trans> : null;
|
||||||
|
|
||||||
export const localhostValidator = value =>
|
export const localhostValidator = value =>
|
||||||
localhostRegex.test(value)
|
localhostRegex.test(value) ? (
|
||||||
? 'Remember to submit a publicly visible app URL.'
|
<Trans>validation.publicly-visible-url</Trans>
|
||||||
: null;
|
) : null;
|
||||||
|
|
||||||
export const composeValidators = (...validators) => value =>
|
export const composeValidators = (...validators) => value =>
|
||||||
validators.reduce((error, validator) => error ?? validator?.(value), null);
|
validators.reduce((error, validator) => error ?? validator?.(value), null);
|
||||||
|
Reference in New Issue
Block a user