Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
value.forEach(function(subvalue) {
var subtag = subvalue ? tags.type(subvalue, label) : null
var data = subtag ? subtag.data.record.Description : null
if (data) {
// Fix bug in `language-tags`, where the description of a tag when
// indented is seen as an array, instead of continued text.
if (subtag.data.subtag === 'ia') {
data = [data.join(' ')]
}
keywords = keywords.concat(
data
.join(' ')
.toLowerCase()
.split(' ')
)
renderFlag(option) {
const { showLanguageName, langTranslator } = this.props;
const tag = tags(option.value);
let langClasses = '';
if (tag.valid() === false) {
// the default language
const defaultName = typeof (langTranslator) === 'function' ? langTranslator('default') : 'default';
return (
<div>
<div title="{option.value}">
{ showLanguageName ? <div title="{defaultName}">{defaultName}</div> : null }
</div>
);
}
</div>
static parse (name) {
let parts = name.split(/[-_]/)
let i = 0
let lang = []
for (const type of ['language', 'extlang', 'script', 'region', 'variant']) {
if (i < parts.length) {
lang.push((tags.type(parts[i], type) && (type !== 'region' || parts[i].match(/^[A-Z]+$/))) ? parts[i++] : '*')
}
}
return _.dropRightWhile(lang, p => p === '*').join('-') || '*'
}
export function parseRange (name) {
let parts = name.split(/[-_]/)
let i = 0
let lang = []
for (const type of ['language', 'extlang', 'script', 'region', 'variant']) {
if (i < parts.length) {
lang.push((tags.type(parts[i], type) && (type !== 'region' || parts[i].match(/^[A-Z]+$/))) ? parts[i++] : '*')
}
}
return _.dropRightWhile(lang, p => p === '*').join('-') || '*'
}
.filter(l => tags(l).valid())
.map(tag => ({ label: tag, value: tag }));