LanguageTranslatorTwig by justb3a

Adds twig support for language translator.

WARNING: This repository is no longer maintained

This repository will not be updated. The repository will be kept available in read-only mode.

ProcessWire

Template Twig Replace Language Support

Adds twig support for language translator list.

Supports the following modules:

Installation


  1. Clone the module and place TemplateTwigReplaceLanguageSupport in your site/modules/ directory.
git clone https://github.com/justonestep/processwire-templatetwigreplacelanguagesupport your/path/site/modules/TemplateTwigReplaceLanguageSupport
  1. Login to ProcessWire admin and click Modules.
  2. Click "Check for new modules".
  3. Click "install" next to the new TemplateTwigReplaceLanguageSupport module. This module requires TemplateTwigReplace as well as LanguageTranslatorList module.
  4. That's all!

Usage


To get your .twig files listed as well, you need to wrap the phrases like this:

{{ __('text to translate', 'filepath/filename relative to site/templates/') }}
{{ __('another text to translate', 'home') }}
{{ __('one more text to translate', 'partials/header') }}
  • first line - general usage
  • second line - example for a text in site/templates/home.twig
  • third line - example tor a text in site/templates/partials/header.twig

Often used translations


You could wrap often used translations in a file called _strings.twig placed in site/templates. Doing this you can copy this file between various ProcessWire installations und reuse it. Make sure to copy also the corresponding json file and import it.

Calling such a translation in another file is really easy, you don't have to provide a translation domain:

{{ __('Save') }}

Now have a look at _strings.twig, in this file you need to have the same entry (one per line) including a translation domain.

Example on how _strings.twig could look like:

{# Intentionally commented out

{% set s = '_strings' %}

{{ __('Save', s) }}
{{ __('Send', s) }}
{{ __('Email address', s) }}

#}

Enable the Twig Intl Extension


The Intl Extension provides the localizeddate, localizednumber and localizedcurrency filters.

First of all, you will need the PHP intl extension, as the Twig extension is built on top of that.

The Twig Intl extension will throw an Exception if the PHP intl extension is not enabled.

Installation instructions can be found in the official PHP documentation.

Go to module settings (Template Twig Replace Language Support) and activate the checkbox.

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #515
    In the 515th issue of ProcessWire Weekly we’ll check out the latest core updates, new modules, and more. Read on!
    Weekly.pw / 23 March 2024
  • Invoices Site Profile
    The new invoices site profile is a free invoicing application developed in ProcessWire. It enables you to create invoices, record payments to them, email invoices to clients, print invoices, and more. This post covers all the details.
    Blog / 15 March 2024
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH