Add management command to populate languages
This commit is contained in:
parent
f67437c27d
commit
0b2caafbde
0
lang/management/__init__.py
Normal file
0
lang/management/__init__.py
Normal file
0
lang/management/commands/__init__.py
Normal file
0
lang/management/commands/__init__.py
Normal file
15
lang/management/commands/setuplang.py
Normal file
15
lang/management/commands/setuplang.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from lang.models import Language
|
||||||
|
from translate.lang import data
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Populates language definitions'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
for code, props in data.languages.items():
|
||||||
|
lang, created = Language.objects.get_or_create(
|
||||||
|
code = code,
|
||||||
|
name = props[0],
|
||||||
|
nplurals = props[1],
|
||||||
|
pluralequation = props[2])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user