Created
November 26, 2011 22:20
-
-
Save j/1396401 to your computer and use it in GitHub Desktop.
Ads the ability to use translations with or without variables in flash messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
#################### | |
## Flash Messages ## | |
#################### | |
flash.user.recover.password.already.requested: | | |
Oops %username%! We see that you've already requested a password within the last 24 hours. Check your email to reset it! | |
flash.notice.this.works.yay: "This flash system works, yay!" | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
[...] | |
$session->setFlash('error', array('flash.user.recover.password.already.requested', array('%username%' => $user->getUsername()))); | |
$session->setFlash('notice', 'flash.notice.this.works.yay'); | |
[...] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Some Title</title> | |
</head> | |
<body> | |
{# start flash messages #} | |
{% for key, flash in app.session.getFlashes() %} | |
<div class="flash-message {{ key }}"> | |
{{ flash[0]|default(flash) | trans(flash[1]|default({})) | raw }} | |
</div> | |
{% endfor %} | |
{# end flash messages #} | |
<div id="content"> | |
{% block content '' %} | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment