Which PO editor can extract messages from twig files? - twig

There is a lot of PO editors, you can find some of them here: What good alternatives to poEdit are there?
But which one can extract messages from twig files?
{% trans %}Hello %name%{% endtrans %}
There is some way to use poedit, but I'm looking for a better way.

I think there is no PO editor that can parse Twig emplates. Poedit can do it with the help of Twig Gettext Extractor.
The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

I use the following two npm modules xgettext-template and gettext-volt. Works perfectly since Volt templates have nearly the same syntax as Twig templates.
EDIT 2021:
You could also purchase a Poedit Pro licence:
Work with Twig and Volt templates
Twig is one of the most popular templating languages for web development, used by WordPress, Craft CMS, Symfony, Drupal, or Grav; Volt is used by Phalcon. Poedit Pro supports extraction of translation strings from Twig and Volt templates out of the box.

Related

X Cart functionality with Twig, resources, creating a theme

I've recently started making a website using the X-Cart platform.
I've read some of pages from the official documentation, but a lot of things do not match the current version of X-Cart (5.3).
From what I understand, they switched from Smarty to Twig, but the file locations and hierarchy have changed as well. Even the database structure is modified and old tables don't have the same names.
I'm currently trying to entirely replace the header / footer of my website. The HTML files are included in lists and displayed with twig, but I don't know how to find those specific files.
Also, I've used the Webmaster Kit add-on in order to find the templates. The problem is that every single element displayed on the page is built from multiple places. Most of them can be found in /customer/layout/, but are part of lists such as layout.header, so the twig files only include the wrappers and retrieve the rest of the code from the database, at least that's my understanding of the situation.
{##
# Header logo
#
# #ListChild (list="layout.header", weight="100")
#}
<div id="{{ this.getUniqueId('logo') }}" class="company-logo">
<img src="{{ this.getLogo() }}" alt="{{ t('Home') }}" />
</div>
I tried accessing layout.header through my database, but the table shown in the documentation doesn't exist anymore.
Could someone please explain the hierarchy and guide me through the steps to create a custom header / footer ?
I did create my costum module, but I still don't know which files are the right to edit in order to make changes happen on my website.
Thank you, let me know if you need additional details.
The header section is defined by the skins/customer/layout/header/main.header.twig template or you can just assign all needed templates to layout.header view list and it will have the same effect. You may also want to remove existing templates and viewer classes from this list.
All these procedures are explained here:
http://devs.x-cart.com/en/getting_started/step_2_-_applying_design_changes.html
http://devs.x-cart.com/en/design_changes/basic_guide_to_theme_creation.html
If you want to look up what templates and viewer classes are in the list, then you can run following MySQL query:
SELECT * FROM xc_view_lists WHERE list="layout.header";
As for footer, the layout.footer defines this area or just override the skins/customer/layout/footer/main.footer.twigtemplate.
Hope, it helps.
Tony

Twig write html comment of template name used to assist debugging on large projects

Is it posisble in Twig to print a comment before and after each twig template used?
Twig - Automatically insert templatename as html comment
The above question didn't not really come up with an answer.
I have seen this functionality once in ezplatofrm, is there a handy wrapper i can call?

Custom HTML in Jade Template

I'd like to accomplish something in jade, but not sure on the best approach. I want to have several product pages on a website, and most of these product pages will have the same layout and design, so I'm going to create one jade template. However, I would love to be able to insert some custom HTML for a couple of product pages in particular.
Can I use an include or something to optionally add custom HTML?
You could use jade partials to show different snippets depending on some conditions in the templating context:
if user.description
!=partial(template name[, options])
Or you might use template inheritance and render a different template depending on the same conditional, but this time in your controller. I would probably do the latter.

What exactly is meant by a Template Engine in computing?

From Cash Costello's Elgg 1.8 Social Networking page 287 under What template engine is used? he says, 'Elgg uses PHP as its template engine.'
What exactly is meant by a Template Engine?
Full extract:
What template engine is used?
Elgg uses PHP as its template engine. This results in a flexible view system since the full power of PHP is available. Developers also do not have to learn a new template language to use Elgg as they would with an engine like Smarty. On the downside, an expressive template language such as PHP is a temptation to mix controller code into the views.
A template (in this context) is an HTML file whose contents are dynamically filled in to produce the final page you're seeing. There are myriads of ways how this "dynamic filling in" can happen, from specialised XML transformation syntaxes to DOM manipulators. "PHP as a template engine" just means that they're using PHP as it was designed: embedded PHP snippets inside of HTML.
If you only know PHP, it may seem strange to you that this needs specific mention. Other languages are not designed to be embeddable inside other languages, so templating is a bit more of a complex task and usually calls for special "templating engines". Such things are becoming more popular in PHP as well though, mostly because their syntax can be simpler and more manageable and they enforce separation of concerns better.
For example, compare to Twig.

What is the difference between include tags and embed tags in expressionengine?

The discussion forum module for expression engine uses {include:file} tags in its templates like in forum_themes/developer/forum_index/main_forum_list.html:
{include:table_heading}
{include:table_rows}
{include:table_footer}
I've searched for the include tag documentation but I can't find it anywhere? What is the include tag and when/where should it be used? Is it specific to the discussion forum module?
I cannot speak to the scope of the {include:file} tag but for most purposes the {embed} tag is what you will be using in ExpressionEngine to include/embed other bits of code.
Other alternatives, depending on the information you would like to include in your page, are the Snippets, Global Variables, or for more complex information LowVariables
Forums are quite difficult to customize and there is very little documentation but the include for forums essentially acts as an embed.
For customizing your forums I would recommend looking at using at the Scaffold Theme on Devot:ee
It should also be noted that {include:file} only work in the forum template code and most standard EE tags (such as the {embed} tag) don't work in the forum templates. Why? I don't know, but dems da rules. :)
There is no documentation on the {include:XXX} tag as it is only used in the Forum templates.
You will never use this tag in normal EE templates. In EE templates you will use an {embed="group/template"} tag or a Snippet depending on your needs.
In addition to embedding templates within each other, you can also create shared layouts for your templates. A layout can be thought of as a wrapping template or a reverse embed. To use a template you use the {layout=""} tag at the top of your template:
{layout="template_group/template"}

Resources