2017 © Pedro Peláez
 

project cake-lazytranslations

Lazy translations for cakephp

image

jonathan-neugber/cake-lazytranslations

Lazy translations for cakephp

  • Saturday, July 15, 2017
  • by jonathan-neugber
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

License, (*1)

A CakePHP 3 plugin that overrides the default __ translation function to enable lazy evaluation., (*2)

Preface

For now this is only a prototype/proof of concept., (*3)

Use case

Let's say you define some translations in a configuration file which is loaded in the bootstrap.php. But afterwards in the code the locale in the I18n class is changed., (*4)

Result: The translations in the config are in a different locale than those evaluated after changing the locale., (*5)

Solution

__ now returns an object that contains everything needed to create the translation but is only evaluated when cast to a string., (*6)

Installation

1. require the plugin in composer.json

"require": {
    "jonathan-neugber/cake-lazytranslations": "dev-master",
}

2. Include the plugin using composer

Open a terminal in your project-folder and run, (*7)

$ composer update

3. Load the plugin config/functions.php

Now here it gets a bit tricky. As you can't yet set the order of loaded files in the composer.json you need it manually add it in the index.php file BEFORE the autoloader.php (Same applies for the bin/cake.php file for the shell)., (*8)

require dirname(__DIR__) . '/vendor/jonathan-neugber/cake-lazytranslations/config/functions.php';
require dirname(__DIR__) . '/vendor/autoload.php';

The Versions

15/07 2017

dev-master

9999999-dev

Lazy translations for cakephp

  Sources   Download

MIT

The Requires