1

I'm using gettext in JavaScript with following construction:

File: script.js.php:

createDynamicForm(formId, '<?php echo(_("Hromadný report")); ?>', data, '', '');

Then I have a link to this file in my page configuration:

<script type='text/javascript' src='".$root."javascript/"."script.js.php'></script>

I also have this item in my PO file:

CZ    
#: javascript/script.js.php:35
msgid "Hromadný report"
msgstr ""

EN:
#: javascript/script.js.php:35
msgid "Hromadný report"
msgstr "Summary report"

Unfortunatelly it is not working for me. After page is refreshed I can see only the CZ words not EN words. In principle for clear PHP files the gettext is working pretty well for me. It is not working only for JS files renamed to .js.php with this special PHP gettext inline function.

Did I miss something?

Edit: I found that in case this javascript code with the gettext function is inside a PHP code with HTML between < script > tags, it is working well:

<?php

  $var = 1;

?>
  <script> 
     createDynamicForm(formId, '<?php echo(_("Hromadný report")); ?>', data, '', ''); 
  </script> 
<?php

  $var++;

So gettext is not working for me in case it is in separate file linked as axternal JS file.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.