Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.1] Load translations by common way (using FilesLocator) #971

Closed
Koc opened this issue May 16, 2011 · 7 comments
Closed

[2.1] Load translations by common way (using FilesLocator) #971

Koc opened this issue May 16, 2011 · 7 comments

Comments

@Koc
Copy link
Contributor

Koc commented May 16, 2011

Now paths to files with translations adds when container compiles https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L407 . Sometimes needed change way to locate translation file, for example when there are themes, wich can override translations from bundle.

@skydiablo
Copy link
Contributor

hiho!
some cognitions ?

@vicb
Copy link
Contributor

vicb commented Apr 20, 2012

@Koc currently we load from (highest priority first):

  1. app/Resources/translations
  2. app/Resources/<bundle>/translations
  3. bundle\Resources\translations

To me 1 and 2 are equivalent (i.e. you should use one or the other but no make use of the different priorities they have - app is your code).

So the remaining question is where to look for other transaltions: before or after 3 (or should it be configurable) ?

@Koc
Copy link
Contributor Author

Koc commented Apr 22, 2012

Imho translations from theme should have possibility override all other translations.

Edit: I've tangled with priorities %).

@vicb
Copy link
Contributor

vicb commented Apr 23, 2012

@Koc could you provide more details on your use case ? Wouldn't your theme be a bundle ?

@Koc
Copy link
Contributor Author

Koc commented Apr 23, 2012

If it would be a bundle we should register it after all other bundles for overridion translations. But there is other situation: 2 themes with different translations (after compilation we got compiled translations only for one theme).

It looks harder than I've thinked,

@jakzal
Copy link
Contributor

jakzal commented Jul 12, 2014

@Koc is it a real life use case for two themes with different translations?

@sstok
Copy link
Contributor

sstok commented Jul 12, 2014

I do have one use, I have a component which provides some translations.
But there is no way to get them in the bundle with duplicating them, or (as I'm currently doing) using a hack. https://github.com/rollerworks/RollerworksSearchBundle/blob/master/src/Rollerworks/Bundle/SearchBundle/DependencyInjection/Compiler/TranslatorPass.php

I did came up with a "better" solution, which to use the Filesystem::mirror() for copying the translations files using Bundle::boot() but its still a hack.

For themes I'd rather use custom Translator, which falls back to the default when there is no translations available. Mainly because a theme can change at any time, and you'd don't want perform the cache warming again :)

aitboudad added a commit that referenced this issue May 6, 2015
… translation loading paths (Seldaek)

This PR was squashed before being merged into the 2.8 branch (closes #14561).

Discussion
----------

[FrameworkBundle][DX] Add option to specify additional translation loading paths

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #971
| License       | MIT
| Doc PR        | TODO

Thanks to this PR, next time I want to just do:

```
    translator:
        fallback: "%locale%"
        paths: ['%kernel.root_dir%/../vendor/internal/package/translations']
```

I will be able to, and won't have to dig in docs, start building a translation loader before I realize it's not what I want, dig in the framework ext, and then have to write a compiler pass to inject my file to the translator resource paths.

Commits
-------

bba0a25 [FrameworkBundle][DX] Add option to specify additional translation loading paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants