+ Start a Discussion
Stefano AmentaStefano Amenta 

Show a language picklist for knowldge articles in lightning component


I created a custom component that shows a knowledge article in Community (English as default language).

I would like to add in the component a language picklist that shows up only if a translated article exists. For example, if the article is translated in Chinese, I would like the picklist to show Chinese as an option.

Is it such functionality doable? Do you have any suggestions on how I could implement it?

my component:
<aura:component implements="forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global" controller="ArticleContentView_Controller">
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="Article" type="Knowledge__kav" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <div class="title"><h2><aura:unescapedHtml value="{!v.Article.Title}" /> </h2></div>   
    <div class="article-content"><aura:unescapedHtml value="{!v.Article.Article_Content__c}" /></div>
    doInit : function(component, event, helper) 
        var actionArticle = component.get("c.getArticle");        

            recordId : component.get("v.recordId")

        actionArticle.setCallback(this, function(response) {
            component.set("v.Article", response.getReturnValue());

        console.log('>> ' + component.get("v.recordId"));


public with sharing class ArticleContentView_Controller 
    //public String articleId {get; set;}

    public static Knowledge__kav getArticle(ID recordId)
        Knowledge__kav article = [SELECT Id, Title, Article_Content__c FROM Knowledge__kav WHERE Id = :recordId LIMIT 1]; 
        return article;