-
-
Save joelpittet/742f9ee5c9c6ac41c39e to your computer and use it in GitHub Desktop.
Potential Twig version of format_plural() and t()
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
{# Converts to format_plural() #} | |
{% format_plural %} | |
Hey {{ name }}, I have one apple. | |
{% plural apple_count %} | |
Hey {{ name }}, I have {{ count }} apples. | |
{% endformat_plural %} | |
{# Converts to format_plural() #} | |
{% trans %} | |
Hey {{ name }}, I have one apple. | |
{% plural apple_count %} | |
Hey {{ name }}, I have {{ count }} apples. | |
{% endtrans %} | |
{# Converts to t() #} | |
{% trans %} | |
Hello {{ name }}! | |
{% endtrans %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about this syntax?
{% format_plural apple_count %}
Hey {{ name }}, I have {{ apple_count }} apples.
{% singular %}
Hey {{ name }}, I have one apple.
{% endformat_plural %}