Skip to content

Commit 7ebb156

Browse files
committed
Merge branch 'master' of github.com:php-translation/symfony-bundle into Nyholm-patch-1
2 parents ac39f55 + 35d3ecf commit 7ebb156

File tree

15 files changed

+176
-42
lines changed

15 files changed

+176
-42
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
global:
1414
- TEST_COMMAND="composer test"
1515
- SYMFONY_PHPUNIT_VERSION="6.5"
16+
- COMPOSER_MEMORY_LIMIT=-1
1617

1718
matrix:
1819
fast_finish: true
@@ -35,7 +36,6 @@ matrix:
3536
- php: 7.2
3637
env: DEPENDENCIES="dunglas/symfony-lock:^4"
3738

38-
3939
# Latest commit to master
4040
- php: 7.2
4141
env: STABILITY="dev"

Command/DeleteObsoleteCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
*/
2929
class DeleteObsoleteCommand extends Command
3030
{
31-
use BundleTrait, StorageTrait;
31+
use BundleTrait;
32+
use StorageTrait;
3233

3334
protected static $defaultName = 'translation:delete-obsolete';
3435

@@ -72,7 +73,7 @@ protected function configure()
7273
->setName(self::$defaultName)
7374
->setDescription('Delete all translations marked as obsolete.')
7475
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
75-
->addArgument('locale', InputArgument::OPTIONAL, 'The locale ot use. If omitted, we use all configured locales.', null)
76+
->addArgument('locale', InputArgument::OPTIONAL, 'The locale to use. If omitted, we use all configured locales.', null)
7677
->addOption('bundle', 'b', InputOption::VALUE_REQUIRED, 'The bundle you want remove translations from.')
7778
;
7879
}

Command/DownloadCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
use Translation\Bundle\Service\CacheClearer;
2121
use Translation\Bundle\Service\ConfigurationManager;
2222
use Translation\Bundle\Service\StorageManager;
23-
use Translation\Bundle\Model\Configuration;
2423

2524
/**
2625
* @author Tobias Nyholm <[email protected]>
2726
*/
2827
class DownloadCommand extends Command
2928
{
30-
use BundleTrait, StorageTrait;
29+
use BundleTrait;
30+
use StorageTrait;
3131

3232
protected static $defaultName = 'translation:download';
3333

Command/ExtractCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function configure()
8989
->setName(self::$defaultName)
9090
->setDescription('Extract translations from source code.')
9191
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
92-
->addArgument('locale', InputArgument::OPTIONAL, 'The locale ot use. If omitted, we use all configured locales.', false)
92+
->addArgument('locale', InputArgument::OPTIONAL, 'The locale to use. If omitted, we use all configured locales.', false)
9393
->addOption('hide-errors', null, InputOption::VALUE_NONE, 'If we should print error or not')
9494
->addOption('bundle', 'b', InputOption::VALUE_REQUIRED, 'The bundle you want extract translations from.')
9595
;

Command/StatusCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ protected function configure()
6868
->setName(self::$defaultName)
6969
->setDescription('Show status about your translations.')
7070
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
71-
->addArgument('locale', InputArgument::OPTIONAL, 'The locale ot use. If omitted, we use all configured locales.', false)
71+
->addArgument('locale', InputArgument::OPTIONAL, 'The locale to use. If omitted, we use all configured locales.', false)
7272
->addOption('json', null, InputOption::VALUE_NONE, 'If we should output in Json format')
73-
->addOption('bundle', 'b', InputOption::VALUE_REQUIRED, 'The translations for bundle you want to check.')
73+
->addOption('bundle', 'b', InputOption::VALUE_REQUIRED, 'The bundle for which you want to check the translations.')
7474
;
7575
}
7676

Controller/WebUIController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1818
use Symfony\Component\Intl\Intl;
19+
use Symfony\Component\Intl\Locales;
1920
use Symfony\Component\Translation\MessageCatalogue;
2021
use Translation\Bundle\Exception\MessageValidationException;
2122
use Translation\Bundle\Service\StorageService;
@@ -250,7 +251,9 @@ private function getMessageFromRequest(Request $request)
250251
private function getLocale2LanguageMap()
251252
{
252253
$configuredLocales = $this->getParameter('php_translation.locales');
253-
$names = Intl::getLocaleBundle()->getLocaleNames('en');
254+
$names = class_exists(Locales::class)
255+
? Locales::getNames('en')
256+
: Intl::getLocaleBundle()->getLocaleNames('en');
254257
$map = [];
255258
foreach ($configuredLocales as $l) {
256259
$map[$l] = isset($names[$l]) ? $names[$l] : $l;

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private function addAutoTranslateNode(ArrayNodeDefinition $root)
187187
->arrayNode('fallback_translation')
188188
->canBeEnabled()
189189
->children()
190-
->enumNode('service')->values(['google', 'yandex'])->defaultValue('google')->end()
190+
->enumNode('service')->values(['google', 'yandex', 'bing'])->defaultValue('google')->end()
191191
->scalarNode('api_key')->defaultNull()->end()
192192
->end()
193193
->end()

Readme.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,56 @@
1313

1414
## Install
1515

16-
Via Composer
16+
Install this bundle via Composer:
1717

1818
``` bash
1919
$ composer require php-translation/symfony-bundle
2020
```
2121

22+
If you're using [Symfony Flex][symfony_flex] - you're done! Symfony Flex will create default
23+
configuration for you, change it if needed. If you don't use Symfony Flex, you will need to do
24+
a few more simple steps.
25+
26+
1. First, register the bundle:
27+
2228
```php
23-
class AppKernel extends Kernel
24-
{
25-
public function registerBundles()
26-
{
27-
$bundles = array(
28-
// ...
29-
new Translation\Bundle\TranslationBundle(),
30-
}
31-
}
32-
}
29+
# config/bundles.php
30+
return [
31+
// ...
32+
Translation\Bundle\TranslationBundle::class => ['all' => true],
33+
];
3334
```
3435

35-
An example configuration looks like this:
36+
2. Then, configure the bundle. An example configuration looks like this:
3637

3738
```yaml
38-
# config.yml
39+
# config/packages/php_translation.yaml
3940
translation:
40-
locales: ["en", "sv"]
41-
symfony_profiler: # must be placed in config_dev.yml
42-
enabled: true
43-
webui:
44-
enabled: true
41+
locales: ["en"]
4542
edit_in_place:
46-
enabled: true
47-
config_name: default # the first one or one of your configs
48-
activator: php_translation.edit_in_place.activator
43+
enabled: false
44+
config_name: app
4945
configs:
5046
app:
51-
dirs: ["%kernel.root_dir%/Resources/views", "%kernel.root_dir%/../src"]
52-
output_dir: "%kernel.root_dir%/Resources/translations"
47+
dirs: ["%kernel.project_dir%/templates", "%kernel.project_dir%/src"]
48+
output_dir: "%kernel.project_dir%/translations"
5349
excluded_names: ["*TestCase.php", "*Test.php"]
5450
excluded_dirs: [cache, data, logs]
5551
```
5652
5753
```yaml
58-
# routing_dev.yml
54+
# config/packages/dev/php_translation.yaml
55+
translation:
56+
symfony_profiler:
57+
enabled: true
58+
webui:
59+
enabled: true
60+
```
61+
62+
3. And the last step, add new routes:
63+
64+
```yaml
65+
# config/routes/dev/php_translation.yaml
5966
_translation_webui:
6067
resource: "@TranslationBundle/Resources/config/routing_webui.yml"
6168
prefix: /admin
@@ -65,12 +72,15 @@ _translation_profiler:
6572
```
6673
6774
```yaml
68-
# routing.yml
75+
# config/routes/php_translation.yaml
6976
_translation_edit_in_place:
7077
resource: '@TranslationBundle/Resources/config/routing_edit_in_place.yml'
7178
prefix: /admin
7279
```
7380
7481
## Documentation
7582
76-
Read the full documentation at [http://php-translation.readthedocs.io](http://php-translation.readthedocs.io/en/latest/).
83+
Read the full documentation at [http://php-translation.readthedocs.io](https://php-translation.readthedocs.io/en/latest/).
84+
85+
86+
[symfony_flex]: https://github.com/symfony/flex

Resources/config/auto_translation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ services:
2323
php_translation.translator_service.yandex:
2424
class: Translation\Translator\Service\YandexTranslator
2525
arguments: ["%php_translation.translator_service.api_key%"]
26+
27+
php_translation.translator_service.bing:
28+
class: Translation\Translator\Service\BingTranslator
29+
arguments: ["%php_translation.translator_service.api_key%"]

Resources/views/SymfonyProfiler/translation.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
{% include "@Translation/SymfonyProfiler/javascripts.html.twig" %}
121121
{% endblock %}
122122

123+
{% block panel %}
124+
{{ block('panelContent') }}
125+
{% endblock %}
126+
123127
{% macro render_table(messages, checkedByDefault = false) %}
124128
<table>
125129
<thead>

0 commit comments

Comments
 (0)