Store Community Support Documentation
Hi There,

I'm trying to use phrases in my javascript file located in myModule/static/jscript/myfile.js using oTranslations but they are coming undefined. I have tried using ex:


But it is coming undefined, I tried searching the core files and I'm sure I'm doing it 'the right way'. I have also tried setting it in the controller file and use it in scripts inside blocks but still the same result occurs.

I also found the following, tried it but still doesn't work and I don't know what to do.

$.ajaxProcess(oTranslations['photo.loading'], 'large')
Be the first person to like this.
In order to use oTranslation phrases they must exist in the document header. To facilitate this some code must be added to the controller to set the header information. It should look something like:

The array information is just the plain text version of the language phrase.

If this operation is successful, then when you load the page you should see your phrase somewhere in the header:
<script type="text/javascript">
oTranslations['friend.show_more_results_for_search_term'] = 'Show more results for "{search_term}"';
oTranslations['medule_name.phrase1'] = 'This name will be linked to this record upon form submission.';
oTranslations['module_name.phrase2'] = 'This will remove the site member to addressbook link upon form submission.';
oTranslations['im.conversations'] = 'Conversations';
oTranslations['im.more_conversations'] = 'More Conversations... 

If you can see your phrase in the header then you should be able to call it with the oTranslation phrase call.
Be the first person to like this.
Worked great thanks!
Be the first person to like this.