头图

Question 1: How to re-read user data after language setting change using UserAccountFacade in Spartacus



The Observable shown above can be extended.

Then use combineLatest to combine with other Observables.

Issue 2: Encountered error message when using outlet: Type before is not assignable to type OutletPosition


在这里插入图片描述

solution:

add outletPosition = OutletPosition; to the component,

Add code to HTML:

 [cxOutletPos]="outletPosition.BEFORE"

Also need to check:

did you add the outlets to the app component html?

For example, add the following code to the Component HTML:

 <outlets></outlets>

Problem 2: HTTP 400 and 404

For the product detail page, just enter a non-existing url and the return value is HTTP 400:

https://cloudapp.azure.com:9002/occ/v2/electronics-spa/cms/pages?pageType=CategoryPage&code=5781122&lang=en&curr=USD

wrong information:

 {
   "errors" : [ {
      "message" : "The value provided is not allowed.",
      "reason" : "invalid",
      "subject" : "code",
      "subjectType" : "parameter",
      "type" : "ValidationError"
   } ]
}

If the content page request does not exist:

https://cloudapp.azure.com:9002/occ/v2/electronics-spa/cms/pages?pageType=ContentPage&pageLabelOrId=%2Ftest&lang=en&curr=USD

Returns the error message:

 "errors" : [ {
      "message" : "No content page found matching the provided label or id: /test",
      "type" : "CMSItemNotFoundError"
   } ]
}

Clients can use custom renderKeyResolver to dynamically decide which page should use which rendering strategy, SSR or CSR.

Storefronts in production mode display non-breaking space characters if a translation is missing for a particular key. To make it easier to catch missing keys, in development mode, Spartacus displays the translation keys, preceded by the name of the block and a colon (for example, [common:form.confirm] ).

If translations are missing, developers can specify alternate languages in order to provide a better user experience. Setting the fallbackLang option ensures that for each missing translation, the equivalent from the fallback language is used.

Here is an example configuration using English as the alternate language:

 import { translations, translationChunksConfig } from '@spartacus/assets';

// ...

providers: [
  provideConfig({
    i18n: {
      resources: translations,
      chunks: translationChunksConfig,
      fallbackLang: 'en',
    },
  }),
];

Translations consist of language and named blocks, so developers can load translation resources only for the current language and current page. The following is an example of the structure of a translation resource:

 interface TranslationResources {
  [lang: string]: {
    [chunkName: string]: {
      [key: string]: any; // value or nested object with keys
    };
  };
}

在这里插入图片描述


注销
1k 声望1.6k 粉丝

invalid