Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Language files with modules

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

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

Page: 1
Go to End
Author Topic: 2270 Views
  • haswalt
    Avatar
    Community Member
    16 Posts

    Language files with modules Link to this post

    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

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Language files with modules Link to this post

    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)

  • haswalt
    Avatar
    Community Member
    16 Posts

    Re: Language files with modules Link to this post

    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

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Language files with modules Link to this post

    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

  • haswalt
    Avatar
    Community Member
    16 Posts

    Re: Language files with modules Link to this post

    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

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Language files with modules Link to this post

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

  • haswalt
    Avatar
    Community Member
    16 Posts

    Re: Language files with modules Link to this post

    Oh yeah silly me.

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

    Harry

    2270 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.