I started working on a project using Silex and Twig and now I'm trying to set up translations. I registered TranslationServiceProvider before TwigServiceProvider
and basically this work's:
{{ app.translator.trans('Homepage') }}
but this doesn't:
{{ 'Homepage'|trans }}
and it returns the following error:
Twig_Error_Syntax in ExpressionParser.php line 573: The filter
"trans" does not exist in "homepage.twig" at line 6
I have read the Silex documentation stating that
when using the Twig bridge provided by Symfony (see
TwigServiceProvider), you will be allowed to translate strings in the
Twig way
but I still don't understand what I am doing wrong and how does the trans filter work.
In my particular case, the issue was that I did not have, twig-bridge declared in composer.json:
"require": {
"silex/silex" : "1.2.2",
"symfony/twig-bridge" : "~2.3",
"twig/twig" : "1.16.2"
}
only silex and twig.
Related
I am running Timber framework on a Wordpress site and in my twig file I have the following code:
<div {{ fn('post_class', ['cell', 'small-12', 'medium-6', 'large-' ~ productTabW, 'xlarge-' ~ productW] ) }}>
On one server it outputs the correct:
<div class="cell small-12 medium-6 large-8 xlarge-6 post-66840 product type-product status-publish has-post-thumbnail product_cat-... ">
On another server I get this:
<divclass="cell small-12="" medium-6="" large-8="" xlarge-6="" post-66835="" product="" type-product="" status-publish="" has-post-thumbnail="" product_cat-....>
You will note the space is removed between the div and class and it looks like the array is expecting key value. The code is the same so I am wondering what php configuration would make Timber output this behaviour.
This was a problem with an outdated Timber installation for PHP 7.4. Updating Timber through composer solved the issue.
Using the REST API, I have no issues creating and updating task items in Todoist. However, I can't seem to remove a due date completely from an item.
This works for setting the due date:
{"due_date":"2020-01-20"}
I have tried the following for removing it with no luck.
{"due_string":"null"}
{"due_string":null}
{"due":{"date": null }}
{"due":{"string": null }}
{"due":null}
{"due":"null"}
How can I accomplish this?
{ due_string: "no due date" } will do the trick.
Have you tried {"due": null}?
According to the API spec it should work.
If you're using Python to generate the request, and depending on how you generate the actual request, you might consider using the None keyword.
in a form i would like modify my url when i change my select option.
When i do this, i have this in my url :
?extension-filter=&extension-list=1019
And i try to get 'extension-list' for give this parameter in my path.
Something like this is possible ? :
<form action="{{ path('my_path', {myoption : app.request.attributes.get('_extension-list') }) }}
You can retrieve a param in query string as follow:
app.request.get('_extension-list')
Hope this help
I was just going through the bolt template for _recordfooter , in the default theme and came across the following liens of code:
{{ __('general.phrase.written-by-on', {
'%name%': record.user.displayname|default(__('Unknown')),
'%date%': record.datepublish|localedatetime("%A %B %e, %Y")
}) }}
I am not quite understanding what the above line of code is really doing and most of all i am not understanding what the usage of the double underline function and also what exactly is 'general.phrase.written-by-on' and where is it coming from ??
They are keyword in the base translation file, in the loacle specific directory under vendor/bolt/bolt/app/resources/translations/
I'm using keystone.js with twig.js as template language. how can i change locale in date?
http://keystonejs.com/docs/database/#fieldtypes-date
I looked through all issues and stackoverflow questions and didn't find answer. in my template i write
{{ post._.publishedDate.format('D MMMM') }} and output is 9 July. I want it to be 9 июля in russian locale.
As far as I know, KeystoneJS use moment.js to set format on date. But how can i change momentjs locale? should i do this on my template or keystone.js or somewhere in middleware or keystone.js file?
I have tried this:
{{ post._.publishedDate.locale('ru').format('D MMMM') }}
{{ post.publishedDate.locale('ru').format('D MMMM') }}
{{ post._.publishedDate.format('D MMMM', 'ru') }}
{{ post._.publishedDate.format('D MMMM', 'ru') }}
{{ post.publishedDate.parse('Do MMM YYYY') }}
{{ _.format(post.publishedDate, 'D MMM') }}
Also i tried in keystone.js file set local variable moment = require('moment') and then in template
{{ moment(post.publishedDate).locale('ru').format('D MMMM') }}
And it didn't work too. What I'm doing wrong?
I can't understand how KeystoneJS work with momentjss and what should I do.
this documentation part is not very helpful.
I think you can set default language for whole site as.
// keystone.js
var moment = require('moment');
moment.locale(locale);