summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale-from-bag.js
blob: 77900084e763ca31ac2e8a8d23bc7f31fddb30c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
export class LocaleFromBag {
    constructor(objectGraph) {
        this.objectGraph = objectGraph;
    }
    /**
     * The current {@link NormalizedStorefront | storefront} for the client
     *
     * This reads directly from the `Bag`, as that is the source of truth
     * for locale information in the "native" clients
     */
    get activeStorefront() {
        // The type-cast here reflects the implicit assumption that any values
        // belonging to the `Bag` have already been normalized
        return this.objectGraph.bag.mediaCountryCode;
    }
    /**
     * The current {@link NormalizedLanguage | language} for the client
     *
     * This reads directly from the `Bag`, as that is the source of truth
     * for locale information in the "native" clients
     */
    get activeLanguage() {
        // The type-cast here reflects the implicit assumption that any values
        // belonging to the `Bag` have already been normalized
        return this.objectGraph.bag.language;
    }
    setActiveLocale(_locale) {
        // Intentional no-op; "native" clients that use the `Bag` as the source
        // of "locale" information do not allow for mutation of the "locale"
    }
    normalize(_unnormalizedLocale) {
        return {
            storefront: this.activeStorefront,
            language: this.activeLanguage,
        };
    }
    deriveLocaleForUrl(locale) {
        return locale;
    }
}
//# sourceMappingURL=locale-from-bag.js.map