-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
'Can access Wagtail admin' is not localized #5341
Comments
This is tricky because this string is stored in the database. Running A possible but hacky looking solution could be to pass the database value into _(permission.name) or: {% trans permission.name %} As long as the literal value is defined somewhere (eg the migration) so that |
@kaedroho when you have the chance, could you add more info on where to do what you suggested? Is it in |
See also #7749. I can see a possible gotcha with @kaedroho's suggestion - if the translated string is part of the migration, and a non-English locale is active when running migrations (e.g. LANGUAGE_CODE is set), it'll end up inserting the non-English text in the database, which then won't be translated by |
As far as I understand, this is exactly what @kaedroho flags, and his suggestion is to call |
It's more subtle than that - there needs to be an occurrence of |
I understood Karl as suggesting we’d have a dummy
|
When declaring custom model permissions as documented in Django, class Mymodel(models.Model):
class Meta:
permissions = [("can_deliver_pizzas", _("Can deliver pizzas"))] the migration generated is: migrations.AlterModelOptions(
name="mymodel",
options={
"permissions": [("can_deliver_pizzas", "Can deliver pizzas")],
"verbose_name": "Mymodel",
},
), so this seems quite safe to only try to translate in the template: {% for custom_perm in content_perms_dict.custom %}
{% trans custom_perm.name as perm_name %}
{% include "wagtailadmin/shared/forms/single_checkbox.html" with name="permissions" value=custom_perm.perm.id checked=custom_perm.selected text=perm_name %}
{% endfor %} |
@SebCorbin The question is, are we 100% confident that there will never be a situation - in anyone's Wagtail project - where a language other than English is active while
to be resolved to something like
while it's scanning for changes to the model state, making it think that there's been a change from what the existing migrations say, and generating a bogus migration in the wagtailadmin app? I've just been trying this out, and haven't been able to break it in that way - but I couldn't be confident that it could never happen, without some very careful reading of the Django source code. Having said that, I see no downside to placing |
Actually, I now see that we've been using that pattern on the Page model's permissions since at least 5.1, so a) if it wasn't safe we'd probably have seen it break by now, and b) we have nothing to gain by avoiding it here :-) |
…t template Since `{% trans some_variable %}` cannot be handled by makemessages, we also need to ensure that any string that arises from Wagtail's native permissions, such as "Can access Wagtail admin" or "Can view", exists somewhere in the python code as a `_("...")` value. Fixes wagtail#5341
I would say yes, because the |
I found there is a problem about localization, as this img:
![image](https://user-images.githubusercontent.com/9018733/58617650-4d79c300-82f3-11e9-9ae1-1cf7263e17ee.png)
wagtail/wagtail/admin/migrations/0001_create_admin_access_permissions.py
Line 21 in 882f8f3
I think it should be change to:
The text was updated successfully, but these errors were encountered: