javascript - Laravel use trans() in jQ added elements - Stack Overflow

I wrote a little Laravel web page and I modify often some inputs with jQuery, now I want to implement a

I wrote a little Laravel web page and I modify often some inputs with jQuery, now I want to implement a multilanguage support. But I dont know how to realize it in jQ.

An example: I have a unsorted list with n items. If the user click on every item I want to display "No more items available" and in German "Keine weiteren Einträge verfügbar". Does somebody have any ideas to realize it?

I using Laravel Blade, the JS content is in a seperated javascript.js file located.

I wrote a little Laravel web page and I modify often some inputs with jQuery, now I want to implement a multilanguage support. But I dont know how to realize it in jQ.

An example: I have a unsorted list with n items. If the user click on every item I want to display "No more items available" and in German "Keine weiteren Einträge verfügbar". Does somebody have any ideas to realize it?

I using Laravel Blade, the JS content is in a seperated javascript.js file located.

Share Improve this question asked Mar 30, 2016 at 7:40 Philipp NiesPhilipp Nies 9694 gold badges21 silver badges40 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You could add the translations in your html page. Example:

<!-- Somewhere in your blade template -->
<script>
    window.translations = {
        noMoreItems: '{{ trans('get.your.translation.here') }}',
        somethingElse: '{{ trans('get.your.other.translation.here') }}',
    };
</script>

Then use those from your script. You might want to provide some defaults when using. Example:

// jQuery script 
var translations = {
    noMoreItems: window.translations.noMoreItems || 'My default translation',
    somethingElse: window.translations.somethingElse || 'My default translation',
};

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745133320a4613078.html

相关推荐

  • javascript - Laravel use trans() in jQ added elements - Stack Overflow

    I wrote a little Laravel web page and I modify often some inputs with jQuery, now I want to implement a

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信