Multilanguage JavaScript Alert - Any Solutions?

I've followed this guide (  to implement multi-language on my site, but I have a few JavaScript alert boxes that display when validation fails, the problem is that they don't support PHP, does this mean there is nothing I could do now?

Any help / suggestions highly appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you have your javascript inside you php file, you can use the same approach as they do with the other html.
The error message could be stored in a php variable, just like  here (exactly like in the guide you linked here):

in the lang.en.php

define('LANG_JS_ERROR1', 'Please fill all fields!');

in the
 define('LANG_JS_ERROR1', 'Please fillos allos fieldos!');


And in the javascript form validation just simply call the php variable like here:

if (theForm.field.value == "")
alert("<?php  echo LANG_JS_ERROR; ?>");
return (false);

The php is processed before the js is processed so this will work.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChiehkaiAuthor Commented:

Thanks for the nice suggestion. I didn the following :

if(null_file_count == upload_range){
            <?php echo $lang['upload_alert_nofile;']; ?>
            return true;

But when I view the source from browser, its :

if(null_file_count == upload_range){
                        return true;

Do you know why it doesn't process the PHP part?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

The java script is actually in the php file or in a separate file? It has to be in the php file and after the language part (where you include the language files).
ChiehkaiAuthor Commented:
Sorry, my bad, made a typo in the script.

Its working perfectly now, thanks.
yes, the one ; in plus :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.