Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/68publishers/translation-bridge
🌉 Integrations of translation components and '68 Publishers bundles
https://github.com/68publishers/translation-bridge
bridge bundle extension nette nette-extension translation
Last synced: 2 months ago
JSON representation
🌉 Integrations of translation components and '68 Publishers bundles
- Host: GitHub
- URL: https://github.com/68publishers/translation-bridge
- Owner: 68publishers
- License: mit
- Created: 2020-11-13T23:19:03.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T00:58:02.000Z (5 months ago)
- Last Synced: 2024-10-07T07:37:22.778Z (3 months ago)
- Topics: bridge, bundle, extension, nette, nette-extension, translation
- Language: PHP
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Translation bridge
## About
The package contains bridges for the following integrations of [symfomy/translation](https://symfony.com/doc/current/translation.html) into [Nette Framework](https://nette.org):
- [contributte/translations](https://github.com/contributte/translation)
Why? Because we want to keep our bundles independent of specific integrations so applications can use any of the integrations mentioned above and will be still compatible with our bundles.
## Installation
The best way to install 68publishers/translation-bridge is using Composer:
```sh
$ composer require 68publishers/translation-bridge
```## Configuration
```neon
extensions:
# if you are using contributte/translation:
translation_bridge: SixtyEightPublishers\TranslationBridge\Bridge\Nette\DI\ContributteTranslationBridgeExtension
```## Usage
### Translation Resources Provider
Extensions can provide paths with translation resources.
```php
use Nette\DI\CompilerExtension;
use SixtyEightPublishers\TranslationBridge\Bridge\Nette\DI\TranslationProviderInterface;final class MyBundleExtension extends CompilerExtension implements TranslationProviderInterface
{
public function getTranslationResources(): array
{
return [
__DIR__ . '/translations',
];
}
}
```### Translator Aware
All services that implement an interface `TranslatorAwareInterface` will automatically receive the Translator instance.
```php
translator->translate('....');
}
}
```### Prefixed Translator Factory
The Container contains an autowired service of type `PrefixedTranslatorFactoryInterface` for creating prefixed translators.
```php
translator = $prefixedTranslatorFactory->create('MyService');
}
}
```### Translator Localizer
The Container contains the service of type `TranslatorLocalizerInterface` for manipulating with the Translator locale.
```php
use SixtyEightPublishers\TranslationBridge\Localization\TranslatorLocalizerInterface;final class MyService
{
public function __construct(
private readonly TranslatorLocalizerInterface $localizer
) {}public function doSomething(): void
{
# Get the current locale
$locale = $this->localizer->getLocale();# Set the new locale
$this->localizer->setLocale('cs_CZ');
}
}
```### Translator Locale Resolver
The Translator's locale can be resolved with own resolvers like this:
```php