Skip to content

Salesforce Lightning Web Component to facilitate multilingual applications development

License

Notifications You must be signed in to change notification settings

ruslan-kurchenko/lwc-polyglot

Repository files navigation

Polyglot

Codacy Badge

Salesforce Lightning Web Component to facilitate multilingual applications development

Features

  • Dynamically resolve Custom Label value by name
  • (in development...): Resolve Field Label
  • (in development...): Resolve Object Label
  • (in development...): Resolve Picklist Options

Usage

Resolve Custom Label

import { LightningElement } from 'lwc';
import { Polyglot } from 'c/polyglot';

const polyglot = new Polyglot();

export default class Examples extends LightningElement {
    connectedCallback() {
        const validLabel = 'Greetings';
        const invalidLabel = 'InvalidName';

        polyglot.getCustomLabels([validLabel, invalidLabel]).then((result) => {
            /*
            result: CustomLabels
              success: false
              messages: {
                InvalidName: "Field $Label.InvalidName does not exist. Check spelling"
              },
              labels: {
                InvalidName: "InvalidName",
                Greetings: "Hello!"
              }
          */
        });
    }
}

Custom Labels Resolve Result

  • success - true/false meta information to indicate if one of labels is invalid
  • messages - meta information to get key/value storage of messages related to invalid labels
  • labels - a custom label values stored in object by their names

License

MIT

About

Salesforce Lightning Web Component to facilitate multilingual applications development

Resources

License

Stars

Watchers

Forks

Packages

No packages published