File tree Expand file tree Collapse file tree 2 files changed +22
-22
lines changed
Expand file tree Collapse file tree 2 files changed +22
-22
lines changed Original file line number Diff line number Diff line change 11import { Injectable } from "@angular/core" ;
22import { BehaviorSubject } from "rxjs" ;
33import { map } from "rxjs/operators" ;
4+ import { merge } from "./../utils/object" ;
45
56const EN = require ( "./en.json" ) ;
67
@@ -34,28 +35,6 @@ export const replace = (subject, variables) => subject.pipe(
3435 } )
3536) ;
3637
37- // custom deep object merge
38- const merge = ( target , ...objects ) => {
39- for ( const object of objects ) {
40- for ( const key in object ) {
41- if ( object . hasOwnProperty ( key ) ) {
42- // since we're dealing just with JSON this simple check should be enough
43- if ( object [ key ] instanceof Object ) {
44- if ( ! target [ key ] ) {
45- target [ key ] = { } ;
46- }
47- // recursivly merge into the target
48- // most translations only run 3 or 4 levels deep, so no stack explosions
49- target [ key ] = merge ( target [ key ] , object [ key ] ) ;
50- } else {
51- target [ key ] = object [ key ] ;
52- }
53- }
54- }
55- }
56- return target ;
57- } ;
58-
5938/**
6039 * The I18n service is a minimal internal singleton service used to supply our components with translated strings.
6140 *
Original file line number Diff line number Diff line change 1+ // custom deep object merge
2+ export const merge = ( target , ...objects ) => {
3+ for ( const object of objects ) {
4+ for ( const key in object ) {
5+ if ( object . hasOwnProperty ( key ) ) {
6+ // since we're dealing just with JSON this simple check should be enough
7+ if ( object [ key ] instanceof Object ) {
8+ if ( ! target [ key ] ) {
9+ target [ key ] = { } ;
10+ }
11+ // recursivly merge into the target
12+ // most translations only run 3 or 4 levels deep, so no stack explosions
13+ target [ key ] = merge ( target [ key ] , object [ key ] ) ;
14+ } else {
15+ target [ key ] = object [ key ] ;
16+ }
17+ }
18+ }
19+ }
20+ return target ;
21+ } ;
You can’t perform that action at this time.
0 commit comments