This is important not only for internationalization, but also for English
app names, consisting of several words. Neither Siteconfig nor Site_config
look pretty.

I think that app name should not be defined as a static variable in
__init__.py file for this reason: if we want to translate the label, we
write _('Site config'), which depends on django.utils.translation, and
translation depends on settings. So, this means that whenever we import any
submodule/subpackage of the app, we also import much of Django machinery.

One alternative (and probably the best one) as suggested by Sergiy is to
put it in admin.py file. Another is to define a function get_app_name() in
__init__.py file.


On Fri, Dec 7, 2012 at 4:57 AM, Pedro J. Aramburu
<paramb...@tres42.com.ar>wrote:

> As I explained on the Django users forums (
> https://groups.google.com/forum/?fromgroups=#!topic/django-users/ZUxZHi_-5ug)
> I'm spanish speaking so my users are too. Writing code in spanish isn't
> pretty and with characters like "á" or "ñ" it's very difficult to name the
> apps a way that would make sense to show on the Admin site.
> That being said, I would like to propose a solution because all the
> tickets and solutions I found won't work properly or are very outdated but
> I need consent and guidance on how to approach it and with the internals of
> django.contrib.admin and django.db.
>
> My solution consists on a class on the __init__.py file on the module
> (app), maybe it can be call AppConfig, where some metadata about the app
> can be stored. Then, django.contrib.admin could pick it up to name the app
> and maybe add a description or help_text and if it's not there it could
> fall back to the previous method with app_label.
>
> As an example:
>
> __init__.py
>
> class AppConfig:
>     verbose_name = 'app pretty name in any'
>     description = 'app short description'
>
> I chose verbose_name to keep it consistent with fields and models but it
> could be called however you want (even pretty_name). Maybe on the future
> AppConfig could be used for other purposes but it has to start somewhere.
> This way you could also use ugettext_lazy to translate the name and
> description.
>
> django.db.models won't need to be touched because they don't need the
> "pretty name" but django.contrib.admin could try to pick up the AppConfig
> to get the pretty name.
>
>
> https://github.com/django/django/blob/1.4.2/django/contrib/admin/sites.py#L365
>
> https://github.com/django/django/blob/1.4.2/django/contrib/admin/sites.py#L421
>
> There it could return the verbose_name.title() or fall back to the
> app_label.title() so then in the template there will be no need to change
> anything (if we don't implement any other functionality yet).
>
> What do you think? Please let me know if it's the best approach and if it
> would be considered to merge it on the project. Mostly because non-english
> speakers need some default solution to make the django admin work for their
> sites but keeping the code in english.
>
> Thank you in advance for your thoughts on this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-developers/-/hwUExTid2UEJ.
> To post to this group, send email to django-developers@googlegroups.com.
> To unsubscribe from this group, send email to
> django-developers+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-developers?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to