Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nero's avatar
Level 1

How to apply the translation in the .js script

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?

0 likes
1 reply

Please or to participate in this conversation.