Open videsignz opened 8 years ago
This is awesome! Thank you very much, this should definitely go into the project! Please gimme some days for testing.
Sweet!! I'm happy you like the idea! :)
Small typo here.
Text::get('FEEDBACK_USER_EMAIL_ALREADY_TAKEN', ['user_email' => $user_email'])
Too many quotation marks ;)
@slaveek Haha, good eye!! Thanks man! Fixed :)
Thanks, this is now implemented in dev + master branch, big thanks to @abmmhasan to doing this!
Would be cool if this would also get a little notice in the readme, so people know how to use this feature!
Works perfectly btw :)
Awesome!! Glad one of my Ideas made it into production :)
I'm so bummed. I can not get this working on my local dev setup. Not sure if it's a php setting that I am missing.
Ok, so....if I change the core Text class to A and use it like A::get();
it works. Not sure what to do about this one. Seems it is a loading order issue.
I isolated the real issue. I know the following is by design, but is there any real downfall to changing it?
Due to the file being loaded once, there is times it loads the texts before the dynamic text variable is assigned.
// load config file (this is only done once per application lifecycle)
if (!self::$texts) {
self::$texts = require('../application/config/texts.php');
}
With that being said, what would be the downfall of eliminating the check...
if (!self::$texts)
You could fix that by doing:
public static function get($key, $data = null)
if ($data) {
return vsprintf(self::$texts[$key], $data);
}
Though then you would have to use it like this:
"FEEDBACK_LOGIN_FAILED" => "Login failed. %s",
// Example from texts file
Text::get('FEEDBACK_LOGIN_FAILED', ['because something']);
Output: Login failed. because something
Hi Chris, While expanding on the app, many times I have needed dynamic/user specific text for positive/negative feedback. But I like keeping with using the texts array because its very easy to manage that way.
So with a little thought and only 6 small lines of code, I came up with a super simple way. This does NOT effect anything in the app, only offers the option for customization.
core/text.php Change this...
To this...
Then right below here....
Add this...
And....viola!
Now in the texts array you can do something like
And when you add feedback you do it like normal yet add the variable like this
This of course will print _Sorry, the email user@mysite.com is already in use._
Just like that you can now have dynamic and user specific texts and feedback messages! Also, I am not saying to change the existing text array here in the repository, just the
core/text.php
class to allow for this feature :)