ExamGecko
Question list
Search
Search

List of questions

Search

Question 184 - Certified B2B Commerce Administrator discussion

Report
Export

A developer needs to implement a custom Lightning web component (LWC) for the storefront.

The LWC contains language-specific text values.

How should the developer translate the text values?

A.
Import static resources for the text values and add them into the LWC.
Answers
A.
Import static resources for the text values and add them into the LWC.
B.
Use a CustomLabel xml file in the LWC to add the text values there.
Answers
B.
Use a CustomLabel xml file in the LWC to add the text values there.
C.
Create custom labels for the text values and import them in the LWC.
Answers
C.
Create custom labels for the text values and import them in the LWC.
D.
Create a custom Metadata object for the text values and query it in the LWC.
Answers
D.
Create a custom Metadata object for the text values and query it in the LWC.
Suggested answer: C

Explanation:

To translate the text values in a custom Lightning web component (LWC) for the storefront, the developer should create custom labels for the text values and import them in the LWC. Custom labels are text values that can be translated into any language that Salesforce supports. The developer can create custom labels in Setup and assign them to a category for easier management. The developer can also use the Translation Workbench to provide translations for the custom labels in different languages.To use the custom labels in the LWC, the developer must import them from the @salesforce/label scoped module and use them in the HTML template or the JavaScript file1. This approach allows the developer to reuse the custom labels across multiple components and leverage the built-in translation features of Salesforce.

Importing static resources or using a CustomLabel xml file are not valid ways to translate the text values in a LWC, as they do not support dynamic language switching or translation workbench integration. Creating a custom metadata object for the text values and querying it in the LWC is possible, but it is more complex and less efficient than using custom labels.Reference:Use Custom Labels in Lightning Web Components

asked 23/09/2024
Dantrez Griffin
34 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first