0

I'm making a plugin (a part on back and another on frontend).

I would like to use my lang.php file (in plugins/me/myplugin/lang/en/lang.php) to my component (I add 'Use Lang') like https://octobercms.com/docs/plugin/localization#file-structure.

How can I use fields on the frontend (in the backend, all works fine) in this lang file (I try, ie, Lang::get('me.myplugin::lang.myfield.name') like https://octobercms.com/docs/plugin/localization#accessing-strings, trans('me.myplugin::lang.myfield.name'), but nothing.

Thanks

Sam
  • 1
  • 1
  • 1

1 Answers1

0

Can you clarify a bit more on this. I'm assuming your Lang file is basically just returning an associative array. In that case, you could just access it like a normal php array.

If I'm wrong, you might want to look at these https://octobercms.com/docs/services/helpers#method-trans

  • Re,I make lang file like https://octobercms.com/docs/plugin/localization#file-structure and would like to access on the frontend (in the backend, all works fine) of my plugin. So, I try with https://octobercms.com/docs/plugin/localization#accessing-strings and your method, but nothing. Thanks – Sam May 09 '17 at 07:28
  • I believe what you are trying to do works only for Backend stuff. For frontend stuff, October has a free plugin. Right here -> http://octobercms.com/plugin/rainlab-translate. You could add this plugin as a dependency for your own plugin and then go from there. – Pratyush Pundir May 09 '17 at 15:43
  • Re, Yes, I can use Translate plugin, but with it, I need re-enter all translations (in system>translate message). So, I will find a way to use my Lang file to the front. Thanks – Sam May 10 '17 at 16:30