Jump to content

Using addJsDefL to add translatable string in JS file


Recommended Posts

This code used to work in previous version if you want to add translatable string to JS file:

{strip}
{addJsDefL name=showmore}{l s='Show all' d='Shop.Theme.Actions' js=1}{/addJsDefL}
{addJsDefL name=showless}{l s='Show less' d='Shop.Theme.Actions' js=1}{/addJsDefL}
{/strip}

It does not seem to be working now. I want to make the options under the "text" option below translatable. Anyone has an idea of how best to achieve this? The code above seem not be working as it brings error.

$('.demo').curtail({
  limit: 140,
  toggle: true,
  text: ['show less', 'show more']
});

 

Link to comment
Share on other sites

I fixed it in another way by using below:

<script type="text/javascript">
// <![CDATA[
    // Translations
    var showmore = '{l s='Show all' d='Shop.Theme.Actions' js=1}';
    var showless = '{l s='Show less' d='Shop.Theme.Actions' js=1}';
//]]>
</script>

And then

	$(function(){
        $('.readmore').curtail({
            limit: 150,
            ellipsis: '...',
            toggle: true,
			text: [(showless), (showmore)]
        });
    });

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...