Language integration into a component

Kevin B Posted in Component Development 5 years ago

Sorry for asking another dumb question... but i'm trying to make my component translation friendly by making use of the locale files and ossn_print. I have a file named: ossn_en.php in the component/locale folder as below:

$en = array(
'webchat' => 'Web Chat',
'com:webchat:menu' => 'Web Chat',
'com:webchat:homebutton' => 'Home',
'com:webchat:input:placeholder' => 'Type a message',
'com:webchat:menu:settings' => 'Settings',
'com:webchat:menu:addcontact' => 'Add contact'

);
ossn_register_languages('en', $en);

I've then added the following into the PHP page template:

<a href="<?php echo ossn_site_url('home'); ?>" class="button"><i class="fa fa-home fa-fw" aria-hidden="true"></i> <span><?php ossn_print('com:webchat:homebutton'); ?></span></a>

For some reason the ossn_print is not working, just returns empty. Even using some core ossn keys like 'photos:ossn' are still coming back blank.

Does the ossn_print() not work on custom pages?
ossn_site_url() works fine.

Replies
gb Kevin B Replied 5 years ago

I said it was a dumb question! Lol. Sorry. I'll go hide in my corner again!

German Michael Zülsdorff Replied 5 years ago

Does the ossn_print() not work on custom pages?

It would if you just echo the returned string of ossn_print().