File: D:/HostingSpaces/SBogers10/gggg.komma.nl/vendor/komma/kms/resources/js/global/translationService.js
import { axios } from './axiosBootstrapper'
/**
* Translation Service
*
* Connects to laravels translation() helper
*/
class TranslationService {
constructor()
{
this.baseRoute = '/globalisation/translation/';
}
/**
* Returns a promise which resolves into a response with your translation data.
*
* @param {string} key
* @param {object} replace
* @param {string|null} locale
*/
async get(key, replace = {}, locale = null) {
let result = '';
await axios.post(this.baseRoute+'get', {'key': key, 'replace': replace, 'locale': locale}).then((response) => {
result = response.data;
}).catch((error) => {
console.error('Could not get translation key: '+key+'. Because of this error: ', error);
});
return result;
}
}
export { TranslationService }