foundryvtt-reve-de-dragon/module/grammar.js

23 lines
516 B
JavaScript
Raw Normal View History

2020-12-08 03:04:00 +01:00
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;
}
2021-01-26 19:47:18 +01:00
2020-12-08 03:04:00 +01:00
static startsWithVoyel(word) {
return word.match(/^[aeiouy]/i)
}
2021-01-26 19:47:18 +01:00
static toLowerCaseNoAccent(words) {
return words?.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") ?? words;
}
2020-12-08 03:04:00 +01:00
}