File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ export const parse = (content: string) => {
61
61
const arr = ( new Engine ( { } ) ) . parseCode ( content , 'lang' ) . children
62
62
. filter ( child => child . kind === 'return' ) [ 0 ] as any ;
63
63
64
- return parseItem ( arr . expr ) ;
64
+ return convertToDotsSyntax ( parseItem ( arr . expr ) ) ;
65
65
}
66
66
67
67
const parseItem = ( expr ) => {
Original file line number Diff line number Diff line change 3
3
return [
4
4
'failed ' => 'These credentials do not match our records. ' ,
5
5
'password ' => 'The provided password is incorrect. ' ,
6
+ 'foo ' => [
7
+ 'level1 ' => [
8
+ 'level2 ' => 'baren '
9
+ ]
10
+ ]
6
11
];
Original file line number Diff line number Diff line change 3
3
return [
4
4
'failed ' => 'As credenciais indicadas não coincidem com as registadas no sistema. ' ,
5
5
'password ' => 'A palavra-passe indicada está incorreta. ' ,
6
+ 'foo ' => [
7
+ 'level1 ' => [
8
+ 'level2 ' => 'barpt '
9
+ ]
10
+ ],
6
11
];
Original file line number Diff line number Diff line change 1
1
import fs from 'fs' ;
2
- import path from 'path' ;
3
2
import { parseAll , parse , hasPhpTranslations } from '../src/loader' ;
4
3
5
4
beforeEach ( ( ) => {
@@ -20,9 +19,11 @@ it('creates a file for each lang', () => {
20
19
21
20
const langEn = JSON . parse ( fs . readFileSync ( files [ 0 ] . path ) . toString ( ) ) ;
22
21
expect ( langEn [ 'auth.failed' ] ) . toBe ( 'These credentials do not match our records.' ) ;
22
+ expect ( langEn [ 'auth.foo.level1.level2' ] ) . toBe ( 'baren' ) ;
23
23
24
24
const langPt = JSON . parse ( fs . readFileSync ( files [ 1 ] . path ) . toString ( ) ) ;
25
25
expect ( langPt [ 'auth.failed' ] ) . toBe ( 'As credenciais indicadas não coincidem com as registadas no sistema.' ) ;
26
+ expect ( langPt [ 'auth.foo.level1.level2' ] ) . toBe ( 'barpt' ) ;
26
27
} ) ;
27
28
28
29
it ( 'transforms .php lang to .json' , ( ) => {
@@ -31,6 +32,14 @@ it('transforms .php lang to .json', () => {
31
32
expect ( lang [ 'failed' ] ) . toBe ( 'These credentials do not match our records.' ) ;
32
33
} ) ;
33
34
35
+ it ( 'transform nested .php lang files to .json' , ( ) => {
36
+ const langPt = parse ( fs . readFileSync ( __dirname + '/fixtures/lang/pt/auth.php' ) . toString ( ) ) ;
37
+ expect ( langPt [ 'foo.level1.level2' ] ) . toBe ( 'barpt' ) ;
38
+
39
+ const langEn = parse ( fs . readFileSync ( __dirname + '/fixtures/lang/en/auth.php' ) . toString ( ) ) ;
40
+ expect ( langEn [ 'foo.level1.level2' ] ) . toBe ( 'baren' ) ;
41
+ } ) ;
42
+
34
43
it ( 'checks if there is .php translations' , ( ) => {
35
44
const hasTranslations = hasPhpTranslations ( __dirname + '/fixtures/lang/' ) ;
36
45
You can’t perform that action at this time.
0 commit comments