HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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 }