Giter Site home page Giter Site logo

transtest's Introduction

transtest

A basic Drupal 8 module for testing translation within Twig {% trans %} block see t() variable placeholders not appearing to work in Twig {% trans %}

To run the test with this module:

  1. Install this module in D8 the normal way
  2. Enable the 4 multilingual modules
  3. In admin/config/regional/language click Add Language and add Spanish
  4. go to [path/to/drupal]/trans-test and then for Spanish [path/to/drupal]/es/trans-test

From the link above:

According to a few sources, the t() variable placeholders are supposed to work in the following way, using a {% trans %} block:

{% set string = '&"<>' %}
{% trans %}
  Escaped: {{ string }}                    <-- default, same as @  (i.e. escape plain text to HTML)
{% endtrans %}
{% trans %}
  Pass-through: {{ string|passthrough }}   <-- same as !  (i.e. insert as is)
{% endtrans %}
{% trans %}
  Placeholder: {{ string|placeholder }}    <-- same as %  (i.e. <em class="placeholder">' . escape plain text to HTML . '</em>')
{% endtrans %}

However, running some tests, I am not able to get this to work.

In the output generated by this module, note that tests 2,3&5 are not supposed to produce translations (and they don't), but that tests 1,4,6,7 should do so; however, only test 1 is producing a translation. None of the tests inside {% trans %}...{% endtrans %} produce translations.

A 2nd thing to note, from looking at the HTML source code, is that for the string '&"<>' the characters are not being escaped (turned into HTML entities), although they might be intended to by tests 1,4,7. (Note that straight Twig does do, this though: {{ string }} ).

transtest's People

Contributors

mark-l6n avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.