foundryvtt-reve-de-dragon/module/grammar.js
2021-01-26 19:48:36 +01:00

23 lines
516 B
JavaScript

const articlesApostrophes = {
'de' : 'd\'',
'le' : 'l\'',
'la' : 'l\''
}
export class Grammar {
static apostrophe(article, word) {
if (articlesApostrophes[article] && Grammar.startsWithVoyel(word)) {
return articlesApostrophes[article] + word
}
return article + ' ' + word;
}
static startsWithVoyel(word) {
return word.match(/^[aeiouy]/i)
}
static toLowerCaseNoAccent(words) {
return words?.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") ?? words;
}
}