Skip to content

Commit

Permalink
Merge branch 'master' of github.com:h5p/h5p-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
devland committed Dec 4, 2024
2 parents 9d2156d + 3e3c912 commit 8ba6b54
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
44 changes: 31 additions & 13 deletions assets/utils/h5p.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,37 +994,55 @@ function removeUntranslatables(field, name, parent, parentName) {
function itemUntranslatable(property, value, parent) {
switch (property) {
case 'label':
return false;
break
case 'description':
return false;
break;
case 'entity':
return false;
break;
case 'explanation':
case 'example':
return false;
break;

case 'description':
case 'placeholder':
return false;
break;
return value.trim().length === 0;

case 'default':
if (typeof value !== 'string') {
return true;
}
// Remove empty strings. One example is Dictation, which has a space for
// a word separator setting.
if (value.trim().length === 0) {
return true;
}
// If this is a number, don't include it
if (!isNaN(value)) {
return true;
}
if (!value.replaceAll(new RegExp(/<\/?[a-z][^>]*>/ig), '')) { // empty html tags
return true;
}
if (new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/).test(value) === true || ['rgb(', 'hsv '].indexOf(value.substr(0, 4)) !== -1) { // color codes

if (
// 3 digit hex color codes
new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/).test(value) === true ||
// 4 digit hex color codes incl. alpha channel
new RegExp(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/).test(value) === true ||
// rgb(a) color codes, sloppy check
new RegExp(/^rgb(a)?(\()?[\d\s,\.\/%]+(\))?$/).test(value) === true ||
// hsl(a) color codes, sloppy check
new RegExp(/^hsl(a)?(\()?[\d\s,\.\/%]+(\))?$/).test(value) === true ||
// hwb color codes, sloppy check
new RegExp(/^hsv?(\()?[\d\s,\.\/%]+(\))?$/).test(value) === true ||
// hwb color codes, sloppy check
new RegExp(/^hwb\([\w\d\s,\.\/%]+\)$/).test(value) === true
// Ignoring lab, oklab, lch, oklch, color() and other color spaces
) { // color codes
return true;
}
if (languageCodes.indexOf(value.toLowerCase()) !== -1) { // language codes
if (languageCodes.indexOf(value) !== -1) { // language codes
return true;
}
break
default:
return true;
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion assets/utils/utility/language-codes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8ba6b54

Please sign in to comment.