moved twig globals to dynamic compiler pass (#264)
This commit is contained in:
26
UPGRADING.md
26
UPGRADING.md
@@ -5,6 +5,32 @@ Database upgrades are currently ONLY provided for MySQL/MariaDB and SQLite.
|
|||||||
If you plan on using e.g. PostgreSQL, please read more about the `bin/console doctrine:migrations:diff` and
|
If you plan on using e.g. PostgreSQL, please read more about the `bin/console doctrine:migrations:diff` and
|
||||||
`bin/console doctrine:migrations:migrate` commands and contact us, so we can integrate them into the official releases.
|
`bin/console doctrine:migrations:migrate` commands and contact us, so we can integrate them into the official releases.
|
||||||
|
|
||||||
|
## 0.4 (not yet released)
|
||||||
|
|
||||||
|
In the time between 0.3 and 0.4 there was a release of composer that introduced a BC break,
|
||||||
|
which leads to problems between Composer and Symfony Flex, resulting in an error like this when running it:
|
||||||
|
|
||||||
|
```
|
||||||
|
[ErrorException]
|
||||||
|
Declaration of Symfony\Flex\ParallelDownloader::getRemoteContents($originUrl, $fileUrl, $context) should be compatible with Composer\Util\RemoteFilesystem::getRemoteContents($originUrl, $fileUrl, $context, ?array &$responseHeaders = NULL)
|
||||||
|
```
|
||||||
|
|
||||||
|
This can be fixed by updating composer before the Kimai update and running composer without the flex plugin:
|
||||||
|
```
|
||||||
|
composer self-update
|
||||||
|
sudo -u www-data composer install --no-plugins
|
||||||
|
```
|
||||||
|
|
||||||
|
So the full update goes like that:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git pull origin master
|
||||||
|
sudo -u www-data composer install --no-dev --optimize-autoloader --no-plugins
|
||||||
|
sudo -u www-data bin/console cache:clear --env=prod
|
||||||
|
sudo -u www-data bin/console cache:warmup --env=prod
|
||||||
|
bin/console doctrine:migrations:migrate
|
||||||
|
```
|
||||||
|
|
||||||
## [0.3](https://github.com/kevinpapst/kimai2/releases/tag/0.3) (2018-07-22)
|
## [0.3](https://github.com/kevinpapst/kimai2/releases/tag/0.3) (2018-07-22)
|
||||||
|
|
||||||
**Update from 0.2:**
|
**Update from 0.2:**
|
||||||
|
|||||||
@@ -68,8 +68,10 @@ kimai:
|
|||||||
# id: 'de.german#holiday@group.v.calendar.google.com'
|
# id: 'de.german#holiday@group.v.calendar.google.com'
|
||||||
# color: '#ccc'
|
# color: '#ccc'
|
||||||
|
|
||||||
twig:
|
# theme related settings, will be available as twig settings
|
||||||
globals:
|
theme:
|
||||||
kimai_context:
|
# display a warning color if the user has at least X active recordings
|
||||||
box_color: "green" # a color for: TODO ??? find out ???
|
active_warning: 3
|
||||||
active_warning: 3 # display a warning color if the user has at least X active recordings
|
# fallback color for all widgets that don't have a dedicated color
|
||||||
|
# possible options: blue, black, purple, yellow, red, green
|
||||||
|
box_color: 'green'
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class AppExtension extends Extension implements PrependExtensionInterface
|
|||||||
|
|
||||||
$container->setParameter('kimai.languages', $config['languages']);
|
$container->setParameter('kimai.languages', $config['languages']);
|
||||||
$container->setParameter('kimai.calendar', $config['calendar']);
|
$container->setParameter('kimai.calendar', $config['calendar']);
|
||||||
|
$container->setParameter('kimai.theme', $config['theme']);
|
||||||
|
|
||||||
$this->createUserParameter($config, $container);
|
$this->createUserParameter($config, $container);
|
||||||
$this->createTimesheetParameter($config, $container);
|
$this->createTimesheetParameter($config, $container);
|
||||||
@@ -98,6 +99,7 @@ class AppExtension extends Extension implements PrependExtensionInterface
|
|||||||
*/
|
*/
|
||||||
public function prepend(ContainerBuilder $container)
|
public function prepend(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
$configuration = new Configuration();
|
$configuration = new Configuration();
|
||||||
$configs = $container->getExtensionConfig($this->getAlias());
|
$configs = $container->getExtensionConfig($this->getAlias());
|
||||||
try {
|
try {
|
||||||
@@ -115,6 +117,7 @@ class AppExtension extends Extension implements PrependExtensionInterface
|
|||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
33
src/DependencyInjection/Compiler/TwigContextCompilerPass.php
Normal file
33
src/DependencyInjection/Compiler/TwigContextCompilerPass.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DependencyInjection\Compiler;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically adds twig globals.
|
||||||
|
*/
|
||||||
|
class TwigContextCompilerPass implements CompilerPassInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param ContainerBuilder $container
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function process(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$twig = $container->getDefinition('twig');
|
||||||
|
$theme = $container->getParameter('kimai.theme');
|
||||||
|
$durationOnly = $container->getParameter('kimai.timesheet.duration_only');
|
||||||
|
|
||||||
|
$twig->addMethodCall('addGlobal', ['kimai_context', $theme]);
|
||||||
|
$twig->addMethodCall('addGlobal', ['duration_only', $durationOnly]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,17 @@ class Configuration implements ConfigurationInterface
|
|||||||
|
|
||||||
$rootNode
|
$rootNode
|
||||||
->children()
|
->children()
|
||||||
|
->arrayNode('theme')
|
||||||
|
->addDefaultsIfNotSet()
|
||||||
|
->children()
|
||||||
|
->integerNode('active_warning')
|
||||||
|
->defaultValue(3)
|
||||||
|
->end()
|
||||||
|
->scalarNode('box_color')
|
||||||
|
->defaultValue('green')
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
->arrayNode('user')
|
->arrayNode('user')
|
||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
->children()
|
->children()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace App;
|
|||||||
|
|
||||||
use App\DependencyInjection\AppExtension;
|
use App\DependencyInjection\AppExtension;
|
||||||
use App\DependencyInjection\Compiler\DoctrineCompilerPass;
|
use App\DependencyInjection\Compiler\DoctrineCompilerPass;
|
||||||
|
use App\DependencyInjection\Compiler\TwigContextCompilerPass;
|
||||||
use App\Timesheet\CalculatorInterface;
|
use App\Timesheet\CalculatorInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
@@ -66,6 +67,7 @@ class Kernel extends BaseKernel
|
|||||||
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob');
|
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob');
|
||||||
|
|
||||||
$container->addCompilerPass(new DoctrineCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000);
|
$container->addCompilerPass(new DoctrineCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000);
|
||||||
|
$container->addCompilerPass(new TwigContextCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configureRoutes(RouteCollectionBuilder $routes)
|
protected function configureRoutes(RouteCollectionBuilder $routes)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ For the most part Kimai usage should be self-explanatory, so we will only cover
|
|||||||
- [FAQ](faq.md) - some answers to frequently asked questions
|
- [FAQ](faq.md) - some answers to frequently asked questions
|
||||||
- [Emails](emails.md) - transport configuration and handling of emails
|
- [Emails](emails.md) - transport configuration and handling of emails
|
||||||
- [API](developers_api.md) - how to use the JSON API
|
- [API](developers_api.md) - how to use the JSON API
|
||||||
|
- [Translations](translations.md) - all about languages and translations
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
@@ -79,22 +79,9 @@ Be aware that this command will modify all files with violations in the director
|
|||||||
|
|
||||||
Our code-styles are configured in [.php_cs.dist](../../.php_cs.dist).
|
Our code-styles are configured in [.php_cs.dist](../../.php_cs.dist).
|
||||||
|
|
||||||
|
|
||||||
## Translations
|
## Translations
|
||||||
|
|
||||||
We try to keep the number of language files small, in order to make it easier to identify the location of application messages and to unify the codebase.
|
Read more about [languages and translations](translations.md).
|
||||||
|
|
||||||
- If you add a new key, you have to add it in every language file
|
|
||||||
- Its very likely that you want to edit the file `messages` as it holds 90% of our application translations
|
|
||||||
|
|
||||||
The files in `translations/` as a quick overview:
|
|
||||||
|
|
||||||
- `exceptions` only holds translations of error pages and exception handlers
|
|
||||||
- `flashmessages` hold all success and error messages, that will be shown as results from action calls after page reload
|
|
||||||
- `messages` holds most of the visible application translations (like all the static UI elements and form translations)
|
|
||||||
- `pagerfanta` includes the translations for the pagination component
|
|
||||||
- `sidebar` holds all the translations of the right sidebar
|
|
||||||
- `validators` only hold translations related to violations/validation of submitted form data (or API calls)
|
|
||||||
|
|
||||||
## Extending the navigation bar
|
## Extending the navigation bar
|
||||||
|
|
||||||
|
|||||||
43
var/docs/translations.md
Normal file
43
var/docs/translations.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Translations
|
||||||
|
|
||||||
|
We try to keep the number of language files small, in order to make it easier to identify the location of application messages and to unify the codebase.
|
||||||
|
|
||||||
|
- If you add a new key, you have to add it in every language file
|
||||||
|
- Its very likely that you want to edit the file `messages` as it holds 90% of our application translations
|
||||||
|
|
||||||
|
The files in `translations/` as a quick overview:
|
||||||
|
|
||||||
|
- `exceptions` only holds translations of error pages and exception handlers
|
||||||
|
- `flashmessages` hold all success and error messages, that will be shown as results from action calls after page reload
|
||||||
|
- `messages` holds most of the visible application translations (like all the static UI elements and form translations)
|
||||||
|
- `pagerfanta` includes the translations for the pagination component
|
||||||
|
- `sidebar` holds all the translations of the right sidebar
|
||||||
|
- `validators` only hold translations related to violations/validation of submitted form data (or API calls)
|
||||||
|
|
||||||
|
## Add a new language
|
||||||
|
|
||||||
|
As example I choose a new hypothetical language with the locale `xx`.
|
||||||
|
|
||||||
|
Copy each translation file from `translations/*.en.xliff` and rename them to `translations/*.xx.xliff`.
|
||||||
|
|
||||||
|
Adjust the `target-language` in the file header, as example for the new file `exceptions.xx.xliff`:
|
||||||
|
```yml
|
||||||
|
<file date="2018-08-01T20:00:00Z" source-language="en" target-language="xx" datatype="plaintext" original="exceptions.en.xliff">`
|
||||||
|
```
|
||||||
|
|
||||||
|
Adjust the file `config/kimai.yaml` and add the language settings below the key `kimai.languages`:
|
||||||
|
```yaml
|
||||||
|
kimai:
|
||||||
|
languages:
|
||||||
|
xx:
|
||||||
|
date_short: 'd.m.Y'
|
||||||
|
```
|
||||||
|
|
||||||
|
Append the new locale in the file `config/services.yaml` at `parameters.app_locales` divided by a pipe:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
parameters:
|
||||||
|
locale: en
|
||||||
|
app_locales: en|de|ru|it|xx
|
||||||
|
```
|
||||||
|
|
||||||
Reference in New Issue
Block a user