Locale/localeapp

Excluding certain translations from `localeapp push`

floehopper opened this issue · 8 comments

We have some translations which we want to hard-code in our app and not manage via LocaleApp. I tried using the blacklisted_keys_pattern configuration option to exclude them, but when I run localeapp push they are still sent to the server. Is this expected? And, if so, is there a way to achieve what I want...?

Hi @floehopper,

The blacklisted_keys_pattern is only used to prevent the missing translations from being sent to the Locale servers. It's not suitable for your use case.
Currently, it's not possible to "blacklist" some keys that are present in a YAML file pushed to Localeapp. The workaround is to extract these keys into a dedicated YAML file, that won't be pushed on Localeapp.

Thanks. Am I correct in thinking that by default all files in the config/locales directory will be pushed to the server? If so, presumably I'd need to put the files somewhere else, but somehow configure Rails so that it still finds them. Is that right?

Would you be open to a pull request which adds a configuration option to exclude certain files from a generic localeapp push command...?

We are always opened to new PR as long as they included tests.
For you use case you can also specify the files that you want to push
localeapp push config/locales/en.yml or a folder localeapp push config/locales/localeapp/

There is also an option that you can define in your config.
Add the translation_data_directory to your localeapp initializer and the cli will by default push the files inside that folder.
https://github.com/Locale/localeapp/blob/master/lib/localeapp/configuration.rb#L112

Thanks. Am I correct in thinking that by default all files in the config/locales directory will be pushed to the server? If so, presumably I'd need to put the files somewhere else, but somehow configure Rails so that it still finds them. Is that right?

Yes, and a subfolder should be enough, IIRC

Cool - thanks for explaining - I'll give the sub-folder approach a try

That seems to do what I want in combination with adding the files in the subdirectory to config.i18n.load_path in config/application.rb. Thanks again. I'll close this issue now.