nero
191
1
Laravel

How to apply the translation in the .js script

Posted 6 months ago by nero

I created a page to upload images. I use javascript to enhance the appearance. I want to apply the language translation to the CHANGE button in the xxx.js. script. If the html tag is in the blade as usual I use the {{trans ('global.CHANGE')}} pattern. But how do you write if the CHANGE button code is at xxx.js? How do I write in the javascript code in the xxx.js file? the following code code xxx.js:

            fileReader.onload = function(e) {
                // Show thumbnail and remove button.
                $fileTab.prepend(getImageThumbnailHtml(e.target.result));
                $browseFileButton.find('span').text('CHANGE');
                $removeFileButton.css('display', 'inline-block');
            };

Or is there another way?

Please sign in or create an account to participate in this conversation.