| 148 |
lars |
1 |
Translation Component
|
|
|
2 |
=====================
|
|
|
3 |
|
|
|
4 |
The Translation component provides tools to internationalize your application.
|
|
|
5 |
|
|
|
6 |
Getting Started
|
|
|
7 |
---------------
|
|
|
8 |
|
|
|
9 |
```
|
|
|
10 |
$ composer require symfony/translation
|
|
|
11 |
```
|
|
|
12 |
|
|
|
13 |
```php
|
|
|
14 |
use Symfony\Component\Translation\Translator;
|
|
|
15 |
use Symfony\Component\Translation\Loader\ArrayLoader;
|
|
|
16 |
|
|
|
17 |
$translator = new Translator('fr_FR');
|
|
|
18 |
$translator->addLoader('array', new ArrayLoader());
|
|
|
19 |
$translator->addResource('array', [
|
|
|
20 |
'Hello World!' => 'Bonjour !',
|
|
|
21 |
], 'fr_FR');
|
|
|
22 |
|
|
|
23 |
echo $translator->trans('Hello World!'); // outputs « Bonjour ! »
|
|
|
24 |
```
|
|
|
25 |
|
|
|
26 |
Sponsor
|
|
|
27 |
-------
|
|
|
28 |
|
| 688 |
lars |
29 |
The Translation component for Symfony 6.2 is [backed][1] by:
|
| 148 |
lars |
30 |
|
|
|
31 |
* [Crowdin][2], a cloud-based localization management software helping teams to go global and stay agile.
|
|
|
32 |
|
|
|
33 |
Help Symfony by [sponsoring][3] its development!
|
|
|
34 |
|
|
|
35 |
Resources
|
|
|
36 |
---------
|
|
|
37 |
|
|
|
38 |
* [Documentation](https://symfony.com/doc/current/translation.html)
|
|
|
39 |
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
|
|
40 |
* [Report issues](https://github.com/symfony/symfony/issues) and
|
|
|
41 |
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
|
|
42 |
in the [main Symfony repository](https://github.com/symfony/symfony)
|
|
|
43 |
|
|
|
44 |
[1]: https://symfony.com/backers
|
|
|
45 |
[2]: https://crowdin.com
|
|
|
46 |
[3]: https://symfony.com/sponsor
|