+ | sed -rn "2q; /^(${regex})\$/{p;q}; a${default}
+ "
+}
+
+invalidate(){
+ # print default if value matches regex; otherwise print value
+ value="$1"
+ regex="$(printf %s\\n "$2" | sed -r ':X;s;(^|[^\\])((\\\\)*)/;\1\2\\/;g;tX')"
+ # ^^ escape only unescaped slash characters for later insertion
+ default="$3"
+
+ printf %s\\n "${value}" \
+ | sed -rn "2q; /^(${regex})\$/{bX}; p;q; :X;a${default}
+ "
+}
+
+declare -A item_name
+l10n(){
+ [ -n "${item_name[$1]+x}" ] && printf %s "$item_name[$1]" || printf %s "$1"