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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Language files with modules


Go to End


7 Posts   3153 Views

Avatar
haswalt

Community Member, 16 Posts

1 October 2008 at 9:44pm

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

Forum Moderator, 801 Posts

7 October 2008 at 12:41am

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

Community Member, 16 Posts

16 October 2008 at 3:45am

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

Forum Moderator, 801 Posts

16 October 2008 at 3:56am

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

Community Member, 16 Posts

16 October 2008 at 9:22pm

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

Forum Moderator, 801 Posts

16 October 2008 at 9:27pm

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

Avatar
haswalt

Community Member, 16 Posts

16 October 2008 at 9:32pm

Oh yeah silly me.

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

Harry