File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change
1
+ import franc from 'franc' ;
2
+
3
+ export default ( input , allowed ) => {
4
+ const detected = franc . all ( input )
5
+ . filter ( lang => lang [ 1 ] >= 0.45 )
6
+ . map ( lang => lang [ 0 ] ) ;
7
+
8
+ // franc spits out ['und'] when unable to
9
+ // guess any languages, let it through in this case
10
+ const matches = detected [ 0 ] === 'und' ||
11
+ detected . indexOf ( allowed ) > - 1 ;
12
+
13
+ return {
14
+ matches,
15
+ detected
16
+ } ;
17
+ } ;
Original file line number Diff line number Diff line change 1
- import franc from 'franc ' ;
1
+ import ensureLanguage from '../library/ensure-language ' ;
2
2
3
3
export default ( parsed , when , value ) => {
4
4
const negated = when === 'never' ;
5
- const detected = franc . all ( parsed . subject )
6
- . filter ( lang => lang [ 1 ] >= 0.45 )
7
- . map ( lang => lang [ 0 ] ) ;
8
-
9
- // franc spits out ['und'] when unable to
10
- // guess any languages, let it through in this case
11
- const matches = detected [ 0 ] === 'und' ||
12
- detected . indexOf ( value ) > - 1 ;
5
+ const { matches, detected} = ensureLanguage ( parsed . subject , value ) ;
13
6
14
7
return [
15
8
negated ? ! matches : matches ,
You can’t perform that action at this time.
0 commit comments