Kdyby / Translation

Integration of Symfony/Translation into Nette Framework
https://packagist.org/packages/kdyby/translation
Other
89 stars 84 forks source link

Namespacing of resources domain #146

Closed mabar closed 6 years ago

mabar commented 6 years ago
public function getTranslationResources() {
   return ['vendor.package' => '__DIR__ . '/../translations'];
}
translations
--sub1
----sub2

Currently if we have file translations/sub1/sub2/messages.en_US.neon domain of this resource is only messages. It is very bad for modularity and forces to make filenames like vendor.package.sub1.sub2.messages.en_US.neon

With this PR domain is builded from key under which is translations folder provided and from subfolders structure. Domain messages becomes vendor.package.sub1.sub2.messages

@enumag Before this PR is largely unuseful to use keys and subfolders, but it is still BC break. Should we release new version?

enumag commented 6 years ago

Personally I'm against ideas like this. I'd rather have a minimal integration of symfony/translation to nette without any additional features at all (ok with neon adapter as the only exception). So if file and directory names are not optimal for you I'd recommend sending a PR to Symfony instead or implementing it otherwise. Or you can convince Filip to merge this.

mabar commented 6 years ago

@fprochazka What do you think? Is it acceptable solution?

mabar commented 6 years ago

Note: This is not ready yet. Latte macros auto-recognize as domain only characters before first dot. Dots in current state represent nesting in configuration file. It is required to separate domain and message arguments.

mabar commented 6 years ago

Behavior is now correct when using {translator}. For {_} it remains the same. Question is, if it should use default domain (messages) instead or allow domain in its arguments too.