Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get translations from within another controller? #28

Open
brasileric opened this issue Oct 7, 2015 · 1 comment
Open

How to get translations from within another controller? #28

brasileric opened this issue Oct 7, 2015 · 1 comment
Assignees

Comments

@brasileric
Copy link

Hi,

I want to get the translations of the dataobject from within another controller. Is it possible to do that:

Example:

$sms_data_s = DataObject::get_by_id('SMSTemplate', 1)->SMSContent;

I have translations for SMSContent, but don't know how to call them.

@bummzack bummzack self-assigned this Oct 17, 2015
@bummzack
Copy link
Owner

Have you tried using getLocalizedValue or the shortcut T?
Eg. Something like this:

$sms_data_s = DataObject::get_by_id('SMSTemplate', 1)->T('SMSContent');

Btw. If you're using SilverStripe 3.1 or newer, I suggest you use the newer syntax to get your DataObject:

$sms_data_s = SMSTemplate::get()->byID(1)->T('SMSContent');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants