Skip to content

Commit

Permalink
Use language short name as a key
Browse files Browse the repository at this point in the history
The ID could have been changed in a local instance
  • Loading branch information
rolandgeider committed Mar 2, 2024
1 parent e688a2f commit 0c88e6c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions wger/core/migrations/0017_language_full_name_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@


def update_language_full_name(apps, schema_editor):
mapper = {1: 'German', 2: 'English', 3: 'Bulgarian', 4: 'Spanish', 5: 'Russian', 6: 'Dutch',
7: 'Portuguese', 8: 'Greek', 9: 'Czech', 10: 'Swedish', 11: 'Norwegian', 12: 'French',
13: 'Italian', 14: 'Polish', 15: 'Ukrainian', 16: 'Turkish', 17: 'Arabic',
18: 'Azerbaijani', 19: 'Esperanto', 20: 'Persian', 21: 'Hebrew', 22: 'Croatian',
23: 'Indonesian', 24: 'Chinese', }
mapper = {'de': 'German', 'en': 'English', 'bg': 'Bulgarian', 'es': 'Spanish', 'ru': 'Russian',
'nl': 'Dutch', 'pt': 'Portuguese', 'el': 'Greek', 'cs': 'Czech', 'sv': 'Swedish',
'no': 'Norwegian', 'fr': 'French', 'it': 'Italian', 'pl': 'Polish', 'uk': 'Ukrainian',
'tr': 'Turkish', 'ar': 'Arabic', 'az': 'Azerbaijani', 'eo': 'Esperanto',
'fa': 'Persian', 'he': 'Hebrew', 'hr': 'Croatian', 'id': 'Indonesian',
'zh': 'Chinese', }

Language = apps.get_model("core", "Language")
for language in Language.objects.all():
language.full_name_en = mapper.get(language.id, 'English')
language.full_name_en = mapper.get(language.short_name, 'English')
language.save()


Expand Down

0 comments on commit 0c88e6c

Please sign in to comment.