Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.
Moderator: General Moderators
gautamz07
Forum Contributor
Posts: 331 Joined: Wed May 14, 2014 12:18 pm
Post
by gautamz07 » Mon Oct 10, 2016 11:34 pm
I was just going through the default twig theme files in bolt CMS and came across the following lines of code , in the listing.twig file.
Code: Select all
{% if taxonomytype is defined %}
<h1>
{{ __('general.phrase.overview-for') }}
{% if taxonomy.options[slug] is defined %}
{{ taxonomy.options[slug] }}
{% else %}
{{ slug }}
{% endif %}
</h1>
{# Taxonomies are fetched unordered by design except if 'has_sortorder'
is set to true. This way we keep 'grouping' intact in the listing. #}
{% if not taxonomy.has_sortorder %}
{# If we specified an order in config.yml, sort them here, accordingly: #}
{% set records = records|order(app.config.get('general/listing_sort')) %}
{% endif %}
{% endif %}
My doubt is about the below line of code:
Code: Select all
{{ __('general.phrase.overview-for') }}
The above line i believe outputs some content. But what exactly does
mean and where is it coming from ??
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Tue Oct 11, 2016 12:29 am
I don't know bolt, but functions named __ are typically for translations. Is there a place where those are defined?
gautamz07
Forum Contributor
Posts: 331 Joined: Wed May 14, 2014 12:18 pm
Post
by gautamz07 » Tue Oct 11, 2016 10:28 am
requinix ,somebody actually answered that question on SO here :
http://stackoverflow.com/a/39970060/4381665 ,
I still dont understand what it is being used for.
Also in the below line of code:
Code: Select all
{{ __('general.phrase.overview-for') }}
what is general.phrase.overview-for ?
BTW , i think celauran uses bolt , so he might have a clue
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Tue Oct 11, 2016 11:32 am
If you know the answer to "what is __" then you should know what the answer to "what is it being used for". Hint: it's the same answer.
"general.phrase.overview-for" is the identifier for the string.
Or wait for Celauran. Whatever.
gautamz07
Forum Contributor
Posts: 331 Joined: Wed May 14, 2014 12:18 pm
Post
by gautamz07 » Tue Oct 11, 2016 11:36 am
actually i did't quite understand the usage of __ too