What’s the expected label file format for Lightning Web Runtime OSS

customlabellightning-web-componentslwc-osslwrlwr-oss

In the Lightning Web Runtime OSS documentation, in the "Use Module Providers" section, I can see "Your application components can now statically import labels sourced from JSON files in your project’s $rootDir/src/labels directory".

What is the expected JSON file format ?

Best Answer

After some tests, it looks like the following is working: In the src/labels directory, create one JSON file per locale you want to support, for instance fr.json, en_US.json etc

In each file, format should be like this:

{
    "c.greeting": "Hello World",
    "c.greeting2": "Hello Again"
}

Then you can import your label in your LWC OSS like on the Platform which is pretty cool for reusability:

import GREETING from '@salesforce/label/c.greeting';

Looks like the correct locale is used if the related file exists, otherwise english is used. As soon as a file exists, all labels must be in there (it won't default to english for a specific value, just for a whole file).

This is just what I discovered by testing though and as it's not officially documented it could break at any time. I tried to get some more official information on the related Trailblazer Community Group.