0

how to change language for DataTable We could use following code from the server end.

"oLanguage": {
  "sUrl": "media/language/custom_lang_<?php echo $language ?>.txt"
}

Now I am using data table inside pentaho. I don't have access to the server side code. Is it possible to change the url dynamically using a java script variable ? The following script is not working as the code is converted to a string.

if(locale=='sv'){
    return {"url": "/pentaho/api/repos/pentaho-cdf-dd/lang/rinjan/messages_sv.json"};
}else{
    return {"url": "/pentaho/api/repos/pentaho-cdf-dd/lang/rinjan/messages_ge.json"}
} 

1 Answer 1

1

I guess that you use the Table Component that is built upon DataTable. It gets a property oLanguage that you could initialize it in the postexecution of the component by issuing an ajax request for fetching the json file corresponding to the language you wish.

The property oLanguage just expects the content of the language file in json format : you can try it by copying the content of a language file from there : https://datatables.net/plug-ins/i18n/

Sign up to request clarification or add additional context in comments.

1 Comment

Seems like this will work. Thanks. I will test and mark the solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.