Using Site Text in Javascript

Aurora supports multilingual using the Site Text facility.  If you're wanting to use this within Javascript, so you can give automated responses back, you can use the below feature.  

First of all, you must ensure that in your header, you include a link to the Javascript file, which is called "ac_language_text.js".  You can do this using the guides set out in Including, Minifying and compressing Javascript and CSS, but for clarity, it is a case of calling "rc:ac_language_text".  With this included in your header, you can now create your Site Text.  Aurora will only look for any "part" that begins with "Javascript" and exports it into the  ac_language_text.js file within the _cache/{crc32 hash of selected domain name}/_resources-cache folder. The ac_language_text variable can then be accessed to grab any text that needs translating.

In your header, you could include the following code:

<script type="text/javascript">
	language_iso = "$language_iso";
</script>

Then in the relevant Javascript file, you can include the following:

  if (typeof language_iso === 'undefined') {
      ac_language_text_iso = Object.keys(ac_language_text)[0];
  } else {
      ac_language_text_iso = language_iso;
  }

  ac_language_text_product_details_attribute_required = ac_language_text[ac_language_text_iso]['Product Details']['Javascript: No Attribute Selected'];

You now have a variable called ac_language_text_product_details_attribute_required that can be used in your Javascript.

Example used on home page of aurorademo.co.uk:

<input type="hidden" id="js_site_text_test" value=""/>
{literal}
    <script type="text/javascript">
        if (typeof ac_language_text != "undefined") {
            var ac_language_text_iso = Object.keys(ac_language_text)[0];
            var js_site_text_test = ac_language_text[ac_language_text_iso]['Homepage']['Javascript: Test'];
            $('#js_site_text_test').val(js_site_text_test);
        }
    </script>
{/literal}