create-sitecore-jss 22.2.0-canary.53 → 22.2.0-canary.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,7 +20,8 @@ import { JssContextService } from './jss-context.service';
|
|
|
20
20
|
TranslateModule.forRoot({
|
|
21
21
|
loader: {
|
|
22
22
|
provide: TranslateLoader,
|
|
23
|
-
useFactory: () =>
|
|
23
|
+
useFactory: (transferState: TransferState) =>
|
|
24
|
+
new JssTranslationClientLoaderService(new JssTranslationLoaderService(), transferState),
|
|
24
25
|
deps: [HttpClient, TransferState],
|
|
25
26
|
},
|
|
26
27
|
}),
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { makeStateKey, Injectable } from '@angular/core';
|
|
1
|
+
import { makeStateKey, Injectable, TransferState } from '@angular/core';
|
|
2
2
|
import { TranslateLoader } from '@ngx-translate/core';
|
|
3
|
-
import { EMPTY } from 'rxjs';
|
|
3
|
+
import { EMPTY, of } from 'rxjs';
|
|
4
4
|
|
|
5
|
-
export const dictionaryStateKey = makeStateKey('jssDictionary');
|
|
5
|
+
export const dictionaryStateKey = makeStateKey<{ [key: string]: string }>('jssDictionary');
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
8
|
export class JssTranslationClientLoaderService implements TranslateLoader {
|
|
9
|
-
constructor(
|
|
10
|
-
private fallbackLoader: TranslateLoader,
|
|
11
|
-
) { }
|
|
9
|
+
constructor(private fallbackLoader: TranslateLoader, private transferState: TransferState) {}
|
|
12
10
|
|
|
13
11
|
getTranslation(lang: string) {
|
|
12
|
+
const storedDictionary = this.transferState.get<{ [key: string]: string } | null>(
|
|
13
|
+
dictionaryStateKey,
|
|
14
|
+
null
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
if (storedDictionary !== null && Object.keys(storedDictionary).length > 0) {
|
|
18
|
+
return of(storedDictionary);
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
if (!this.fallbackLoader) {
|
|
15
22
|
return EMPTY;
|
|
16
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sitecore-jss",
|
|
3
|
-
"version": "22.2.0-canary.
|
|
3
|
+
"version": "22.2.0-canary.54",
|
|
4
4
|
"description": "Sitecore JSS initializer",
|
|
5
5
|
"bin": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"ts-node": "^10.9.1",
|
|
64
64
|
"typescript": "~4.9.5"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "8680dbba433414dcc7963f9ae66e71ce85814b96"
|
|
67
67
|
}
|