feat(i18n): url validation translations (#41190)

This commit is contained in:
Shaun Hamilton
2021-02-20 05:02:44 +00:00
committed by GitHub
parent b2ec1a3ef4
commit d70e33c1d2
4 changed files with 20 additions and 8 deletions

View File

@ -474,7 +474,10 @@
"invalid-url": "我们无法验证你的 URL请确保填写正确",
"invalid-protocol": "URL 必须以 http 或 https 开头",
"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": {
"executive": "执行董事freeCodeCamp.org",

View File

@ -474,7 +474,10 @@
"invalid-url": "We could not validate your URL correctly, please ensure it is correct",
"invalid-protocol": "URL must start with http or https",
"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": {
"executive": "Executive Director, freeCodeCamp.org",

View File

@ -474,7 +474,10 @@
"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",
"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": {
"executive": "Director Ejecutivo, freeCodeCamp.org",

View File

@ -1,18 +1,21 @@
import React from 'react';
import { Trans } from 'react-i18next';
// Matches editor links for: Repl.it, Glitch, CodeSandbox, GitHub
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 localhostRegex = /localhost:/;
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 =>
fCCRegex.test(value) ? 'Remember to submit your own work.' : null;
fCCRegex.test(value) ? <Trans>validation.own-work-url</Trans> : null;
export const localhostValidator = value =>
localhostRegex.test(value)
? 'Remember to submit a publicly visible app URL.'
: null;
localhostRegex.test(value) ? (
<Trans>validation.publicly-visible-url</Trans>
) : null;
export const composeValidators = (...validators) => value =>
validators.reduce((error, validator) => error ?? validator?.(value), null);