Javascript, language files, configuration
- by johnnyArt
I'm building a form validation script for one of my sites, and I thought I'd make the error messages international, meaning that depending on the users language I'd give such or such response.
What would the best approach be, for loading a configuration file inside of my class?
Right now I'm using the following structure for a single language:
const config = {
'errorName' : 'error message',
'errorName2' : 'error message',
'errorName2' : 'error message'
}
And calling it like this of course: config['errorName']. But I don't know how to load those variables from a file, let's say 'lang/en.js'