Skip to content

Commit

Permalink
[DM] Add i18n to text "Ajout supplimentaire" for english langue #3
Browse files Browse the repository at this point in the history
  • Loading branch information
hadpro24 committed May 8, 2021
1 parent 5449adc commit c1741dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion forms_fieldset/templates/forms_fieldset/tabular.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2 style="background-color: {{ color }}">{{ label }}</h2>
</tr>
{% endfor %}
<tr class="add-row" id="link-add-row"><td colspan="{{ inline_formset.extra|add:'1' }}">
<a href="#" id="add-info">Ajout supplémentaire</a></td></tr>
<a href="#" id="add-info">{{ title_add }}</a></td></tr>
</tbody>
</table>
</fieldset>
Expand Down
13 changes: 13 additions & 0 deletions forms_fieldset/templatetags/forms_fieldset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import template
from django.contrib.admin.helpers import AdminForm
from django.template.loader import render_to_string
from django.conf import settings

class FieldsetsNotSupported(Exception):
""" form field sets type error, it must be a list """
Expand All @@ -20,9 +21,21 @@ def fieldset(form, fieldsets, color='#79AEC8'):

@register.simple_tag
def inline_fieldset(inline_formset, color='#79AEC8', label='Inline Form'):
LANGEAGE_DATA = {
'en-en': 'Add another',
'en': 'Add another',
'EN-EN': 'Add another',
'EN': 'Add another',
'fr-fr': 'Ajout supplémentaire',
'fr': 'Ajout supplémentaire',
'FR-FR': 'Ajout supplémentaire',
'Fr': 'Ajout supplémentaire',
'de': 'Ajout supplémentaire',
}
context = {
'inline_formset': inline_formset,
'color': color,
'label': label,
'title_add': LANGEAGE_DATA.get(settings.LANGUAGE_CODE, 'Add another')
}
return render_to_string('forms_fieldset/tabular.html', context)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = django-forms-fieldset
version = 0.1.3
version = 0.1.4
description = Django form fieldset inspire django admin fieldset.
long_description = file: README.rst
url = https://github.com/hadpro24/django-forms-fieldset
Expand Down

0 comments on commit c1741dd

Please sign in to comment.