0

I follow this solution :

Translation in JavaScript like gettext in PHP?

js-lang.php :

lang_error_empty_field = "<?php echo _("Lütfen boş alan bırakmayın"); ?>";

signin.php :

<script src="assets/layout/scripts/js-lang.php" type="text/javascript">
</script>
<!-- LAYOUT SCRIPTS END -->

<!-- PAGE SCRIPTS START -->
<script src="assets/pages/scripts/signin.js"></script>
<!-- PAGE SCRIPTS END -->

signin.js :

if (!email || !password) {
    showError(lang_error_empty_field);
    hideError(3000);
    return;
}

The error is :

GET http://localhost:8835/assets/layout/scripts/js-lang.php net::ERR_EMPTY_RESPONSE

Normally gettext works, but i can not use in javascript files. How can i use gettext in javascript ?

UPDATE

error.php :

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include("js-lang.php");
?>

Still same error in here. I can not handle any error.

Community
  • 1
  • 1
  • Is `js-lang.php` throwing any errors? Turn on error reporting, check the PHP logs, and check the response in the browser's debugging tools. The error implies that there's nothing being returned. – David Dec 27 '16 at 15:19
  • @David how do i open error reporting ? – Argenit Ltd Dec 27 '16 at 15:22
  • First Google result for "php error reporting": http://php.net/manual/en/function.error-reporting.php – David Dec 27 '16 at 15:27

0 Answers0