Set lang as a function in javascript