it is boring that lots of code must be created in a Joomla component for backend and also front end. So I would like to use the administrator language file of my custom component for my front end. I found this piece of useful code:
$language = JFactory::getLanguage();
$language->load('com_yourcomponentname', JPATH_ADMINISTRATOR, 'en-GB', true);
But where should I include that piece of code? I've tried it in the index.html file of my frontend template. But this doesn't work!
I've also tried at the beginning of the templates index.html:
$language = JFactory::getLanguage();
$extension = 'com_yourcomponentname';
$base_dir = JPATH_ADMINISTRATOR . DS . 'components' . DS . $extension;
$language_tag = $language->getTag(); // loads the current language-tag
$language->load($extension, $base_dir, $language_tag, true);
$paths = $language->getLanguagePath();
$paths shows me an array with all loaded components including my custom component. The last entry of the array of my custom component refers correct to my administration language file of my component.
D:\htdocs\test\language\en-GB\en-GB.com_yourcomponentname
D:\htdocs\test\language\de-DE\de-DE.com_yourcomponentname
D:\htdocs\test\components\com_yourcomponentname\language\en-EN\en-EN.com_yourcomponentname
D:\htdocs\test\components\com_yourcomponentname\language\de-DE\de-DE.com_yourcomponentname
D:\htdocs\test\administrator\components\com_yourcomponentname\language\en-EN\en-EN.com_yourcomponentname
D:\htdocs\test\administrator\components\com_yourcomponentname\language\de-DE\de-DE.com_yourcomponentname
But the translation of the variables are still not be made. The translation in the backend is working fine with that same file.