Skip to content
Snippets Groups Projects
Commit c03ceef5 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

More sensible language handling on front page.

parent 7c1dd948
Branches
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ from organisms.models import CropGroup ...@@ -24,7 +24,7 @@ from organisms.models import CropGroup
def index(request): def index(request):
# Get front page categories. This is defined in local_settings.py # Get front page categories. This is defined in local_settings.py
message_tags = MessageTag.get_message_tags() message_tags = MessageTag.get_message_tags(translation.get_language())
messages_by_tag = {} messages_by_tag = {}
for message_tag_id in settings.FRONTPAGE_MESSAGE_TAG_IDS: for message_tag_id in settings.FRONTPAGE_MESSAGE_TAG_IDS:
messages = Message.get_messages_by_tag(message_tag_id, translation.get_language()) messages = Message.get_messages_by_tag(message_tag_id, translation.get_language())
......
...@@ -34,10 +34,10 @@ class MessageTag: ...@@ -34,10 +34,10 @@ class MessageTag:
self.local_tag_name = local_tag_name self.local_tag_name = local_tag_name
@staticmethod @staticmethod
def get_message_tags(): def get_message_tags(current_language=settings.VIPSLOGIC_LANGUAGE_CODE):
message_tags = [] message_tags = []
for item in MessageTag.get_message_tags_as_json(): for item in MessageTag.get_message_tags_as_json():
message_tag = MessageTag.get_instance_from_dict(item) message_tag = MessageTag.get_instance_from_dict(item, current_language)
message_tags.append(message_tag) message_tags.append(message_tag)
return message_tags return message_tags
...@@ -47,10 +47,10 @@ class MessageTag: ...@@ -47,10 +47,10 @@ class MessageTag:
return request_result.json() return request_result.json()
@staticmethod @staticmethod
def get_instance_from_dict(item): def get_instance_from_dict(item, current_language=settings.VIPSLOGIC_LANGUAGE_CODE):
local_tag_name = None local_tag_name = None
for tagLocale in item["messageTagLocaleSet"]: for tagLocale in item["messageTagLocaleSet"]:
if tagLocale["messageTagLocalePK"]["locale"] == settings.VIPSLOGIC_LANGUAGE_CODE: if tagLocale["messageTagLocalePK"]["locale"] == current_language:
local_tag_name = tagLocale["localName"] local_tag_name = tagLocale["localName"]
return MessageTag( return MessageTag(
item["messageTagId"], item["messageTagId"],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment