How to see Translation for Custom Label in Lightning Component?

How about this?

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject_describe.htm#apex_methods_system_sobject_describe

If there is a translation already present in Salesforce, you can look it up with a describe function, which then translates it to your locale settings (or somebody else's, whoever is using it).

I'm going to be working with this as well, as I'm currently developing an app that supposedly should also have multi-language support (have to discuss with my supervisor if and which languages, but as a start he sent me this link).

(To be clear: this is APEX code, so you do need an APEX controller attached to your lightning component)


Probably this is a Salesforce bug. I have a similar problem. I'm developing a component as part of managed package. Translations work when I'm inside the development org, but I get only English values when using the component in my test org.

My workaround for this is to add a server side action that would return a map of all the custom labels used in the component and then set it as an attribute of type "Map". (You need to reference in apex or visualforce all labels anyway in order to include them in a managed package)

I don't know if your problem is the same so I submitted another question and sample code for the workaround here https://salesforce.stackexchange.com/a/150840/27814


Options to translate community were applied:

  1. Translation Workbench was used to translate picklists values.
  2. Site.com default community language was switched to German.
  3. Optionally able to implement and use URL parameter.

In case Community builder Admin have to put Label value to component parameter/attribute section: 1. Have to use declaration:

$Label.c.XXX_Label_Name

Where to use
2. Component .js controller:
Have:

< design:attribute name="headerName" label="Header Name"/>
< aura:attribute name="headerName" type="String" />


On Init: 2.1 OR 2.2.

2.1

var headerName = cmp.get("v.headerName")
var labelRef = $A.getReference(headerName)
cmp.set("v.headerName", labelRef)

2.2 Commented label name is a must

//$Label.c.MAH_Contact_Us
cmp.set("v.headerName", $A.get(cmp.get("v.headerName")))

Takes time to load it.

Thanks a lot for the help and ideas!