Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Language files with modules


Reply

7 Posts   2301 Views

Avatar
haswalt

1 October 2008 at 9:44pm Community Member, 16 Posts

Hi all,

I have two questions here:

1) I have created a module and am pretty sure i have the correct directory structure. The module is pretty much empty right now since i am only trying to fix this issue for now. Basically my en_US.php file contains a load of translations, but non of them are being used. I have tried putting an echo and exit into the php file but nothing happens so i assume it is not being loaded at all. How do i fix this?

2) How do i get the current username? I have tried using Member::getName() and Member::getTitle() but both are returning blank. Although i can get the userID from Member::currentUserID().

Thanks for your help all.

Harry

Avatar
Ingo

7 October 2008 at 12:41am Forum Moderator, 801 Posts

1) Can you provide a sample of your en_US.php through pastie.org? Did you i18n::enable() in your _config.php? Are you using _t() to echo the translated strings in your PHP file? Is the echo code in a valid Silverstripe model or controller?

2) $member = Member::currentUser();
echo $member->FirstName;
echo $member->Surname;
echo $member->Title; (firstname and surname)

Avatar
haswalt

16 October 2008 at 3:45am Community Member, 16 Posts

1) my en_US.php file includes:

<?php

global $lang;

$lang['en_US']['TestLinksAdmin_left.ss']['TESTLINKSHELP'] = 'Admin Testing Links Help';

?>

Just as a sample.

i18n::enable() is in my config and i am using _t() to echo.

My silverstripe install won't build the manifest as it says there are more than one file the same!!

Surely you must be able to have more than one language file so that lang files can be distributed with modules?

Plus the tutorial says to create this file.

2) Thanks, perfect!

Cheers

Harry

Avatar
Ingo

16 October 2008 at 3:56am Forum Moderator, 801 Posts

whats the path to your en_US.php relative to the webroot?
do you have a _config.php in your module root?
do you have a _manifest_exclude file in your module /lang folder?

you should create the lang master tables through the i18n/textcollector command, which makes sure its the right format - and is simpler to use than manual copypaste as well :)

Avatar
haswalt

16 October 2008 at 9:22pm Community Member, 16 Posts

Ok so the manifest builder does not complain any more.

How do i run the text collector function to get all my lang stuff together since it is still not displaying in the CMS correctly.

Harry

Avatar
Ingo

16 October 2008 at 9:27pm Forum Moderator, 801 Posts

read the i18n documentation :)
http://doc.silverstripe.com/doku.php?id=i18n

Avatar
haswalt

16 October 2008 at 9:32pm Community Member, 16 Posts

Oh yeah silly me.

any chance you could take a look at my other post. immediately under this one?

Harry