This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

graker
graker

Hi

I'm adding some JS to my plugin. Specifically, a custom button to Markdown Editor toolbar. And I would like to make button's label translatable like other markdown editor buttons. I found $.oc.lang object but from debugger I see that it only contains lang strings from October core and not from my plugin. So the question is how to load strings from my plugin's lang.php as well? Or should I take another approach when I want to translate something in JS?

alxy
alxy

It indeed only considers system files.Maybe we should consider adding a client.php to the lang dir would make these available to the frontend. Of course, this requires to call php artisan october:util compile lang to actually build the client lang file.

graker
graker

I agree, it is quite normal to implement server-side localization at client-side one way or the other. Scanning plugin lang dirs for client.php looks natural and easy for plugin developers to use.

Though to avoid making users rebuild client lang file any time a plugin is updated, it could be useful to run rebuild automatically when october:up is being run.

Last updated

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.