-
Notifications
You must be signed in to change notification settings - Fork 260
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
Keys with dynamic scope arguments in views are parsed as if there were no scope argument #213
Comments
This is fully supported in Dynamic keys, however, need to be listed explicitly, so e.g. if the possible actions are / i18n-tasks-use t('search.foo.title')
/ i18n-tasks-use t('search.bar.title') You can also put them on the same line: / i18n-tasks-use t('search.foo.title') t('search.bar.title') |
Thank you for the quick response.
Since this is used in a view, does that mean that it is not supported? = t(:title_no_results, scope: [:search, params[:action]], query: params[:q]) I'll will use the explicit keys in the |
Ok, I've tried using the below and it didn't work. / i18n-tasks-use t('search.foo.title_no_results')
/ i18n-tasks-use t('search.bar.title_no_results')
/ i18n-tasks-use t('search.foobar.title_no_results')
/ i18n-tasks-use t('search.barfoo.title_no_results')
%h2.no-results-title= t(:title_no_results, query: params[:q], scope: [:search, params[:action]]) I get the following output when I run Missing translations (1) | i18n-tasks v0.9.6
+--------+-------------------------+-------------------------------------------+
| Locale | Key | Value in other locales or source |
+--------+-------------------------+-------------------------------------------+
| all | title_no_results_html | app/views/search/_no_results.html.haml:10 |
+--------+-------------------------+-------------------------------------------+
Any ideas? |
The output of |
Sorry, when I said the last argument, I actually meant to say the first argument after the key! |
Sorry, that was me redacting some key names. In that example it should have been There are hundreds of these examples in my codebase, but I've excluded all other files except this one for now to isolate what is happening. So it's definitely this key 😕
So it should be this? %h2.no-results-title= t(:title_no_results, scope: [:search, params[:action]]), query: params[:q] I've just tried it that way too and it's still not working I'm afraid. |
I've just look at the code for this, and looks like the scope argument is completely ignored if it doesn't consist of literals only ( So you could submit a fix that correctly parses such scope arguments as e.g. Alternatively, in your codebase, you could refactor such keys to not use a scope argument (I thin. In any case |
Fix released in v0.9.9. |
Firstly, sorry for opening a support issue here!
Our app uses translations using the explicitly scoped, symbols form, e.g.
We have a lot of this code in our large codebase.
We also use some dynamic keys, e.g.
I've tried using the following hint using
i18n-tasks-use
but it doesn't work using either of the below comments on the preceding lineSo right now I can't use the
missing
command or RSpec test because of false positives.Am I doing something wrong or is this type of dynamic key not supported?
The text was updated successfully, but these errors were encountered: