Найти - Пользователи
Полная версия: gettext_lazy
Начало » Django » gettext_lazy
1
куиуд
Мне нужно перевести проект. Но у меня проблема с gettext_lazy.

from django.utils.translation import gettext_lazy as _

DEFAULT_PLAYER_NAMES = (
_('Goalkeeper'),
_('Left Defender'),)

class TeamSelectionForm(WapForm):
p1 = forms.CharField(label = “01 ” + DEFAULT_PLAYER_NAMES, max_length = 20)
p2 = forms.CharField(label = “02 ” + DEFAULT_PLAYER_NAMES, max_length = 20)

При слжениии 01 " + DEFAULT_PLAYER_NAMES выдается ошибка cannot concatenate ‘str’ and ‘instance’ objects.
Как эту ошибку исправить?
playpauseandstop
имхо, было бы неплохо попробовать как-то так:
DEFAULT_PLAYER_NAMES = (
    _('%02d Goalkeeper'),
    _('%02d Left Defender'),
)
и
label = DEFAULT_PLAYER_NAMES[0] % 1
label = DEFAULT_PLAYER_NAMES[1] % 2
если не помогло, то:
label = '01 ' + str(DEFAULT_PLAYER_NAMES[0])
label = '02 ' + str(DEFAULT_PLAYER_NAMES[1])
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB