Language integration into a component

Kevin B Posted in Component Development 3 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 ossnprint. I have a file named: ossnen.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'

);
ossnregisterlanguages('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 ossnprint() not work on custom pages?
ossn
site_url() works fine.

Replies
gb Kevin B Replied 3 years ago

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

German Michael Zülsdorff Replied 3 years ago

Does the ossn_print() not work on custom pages?

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