Jump to content

How to use language strings in external JS files?


motomac

Recommended Posts

Posted

I'm making a plugin, main logic of which is in the Javascript controller (dev/js/myscript.js). Is there any easy way to use language strings in this external Javascript file?

Now I have to manually assign needed strings to Javascript variables in the template like this:

var today = {lang="today"};

But I need a lot of language strings, and it's becoming too hard to use this approach.

The same question with the other template plugins like {setting="$settingKey"}.

Posted

And the second question about the settings. As I see in the code, I can't simply use getSetting(settingKey) without predefining settings using ips.setSetting(settingKey) in the templates. Is it a correct way?

Posted

Hello,

You can reference any language string - ultimately javascript language strings are all set in the same manner and are globally accessible.

That is correct about setSetting/getSetting.  Not all ACP settings are passed to javascript inherently, you will need to manually pass any that you want to access.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...