Skip to content

Commit

Permalink
Merge pull request #67 from NatLibFi/SIMPLYE-331-fixes
Browse files Browse the repository at this point in the history
Translation fixes.
  • Loading branch information
jompu authored Apr 27, 2024
2 parents aba44fc + 509be17 commit bab076a
Show file tree
Hide file tree
Showing 15 changed files with 712 additions and 590 deletions.
10 changes: 8 additions & 2 deletions core/feed/annotator/circulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from flask_babel import lazy_gettext as _
from sqlalchemy.orm import Session

import default_lane_names_to_localize
from api.adobe_vendor_id import AuthdataUtility
from api.annotations import AnnotationWriter
from api.circulation import BaseCirculationAPI, CirculationAPI
Expand All @@ -22,6 +23,7 @@
from api.metadata.novelist import NoveListAPI
from core.analytics import Analytics
from core.classifier import Classifier
from core.classifier.localized_names import genres as localized_genre_names
from core.config import CannotLoadConfiguration
from core.entrypoint import EverythingEntryPoint
from core.external_search import WorkSearchResult
Expand Down Expand Up @@ -953,8 +955,12 @@ def annotate_work_entry(
)
if group_uri:
# Finland
# Attempt to translate the group title.
group_title = _(group_title)
# Attempt to translate the group title if it is to be localized.
if (
group_title in default_lane_names_to_localize.lanes.keys()
or group_title in localized_genre_names.keys()
):
group_title = _(group_title)

entry.computed.other_links.append(
Link(href=group_uri, rel=OPDSFeed.GROUP_REL, title=str(group_title))
Expand Down
2 changes: 2 additions & 0 deletions default_lane_names_to_localize.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"Business": _("Business"),
"Chapter Books": _("Chapter Books"),
"Children and Middle Grade": _("Children and Middle Grade"),
"Children & Young Adult": _("Children & Young Adult"),
"Christianity": _("Christianity"),
"Civil War History": _("Civil War History"),
"Classics": _("Classics"),
Expand Down Expand Up @@ -156,6 +157,7 @@
"Women Detectives": _("Women Detectives"),
"Women's Fiction": _("Women's Fiction"),
"World History": _("World History"),
"World Languages": _("World Languages"),
"Young Adult Fiction": _("Young Adult Fiction"),
"Young Adult Nonfiction": _("Young Adult Nonfiction"),
}
15 changes: 14 additions & 1 deletion scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ def _collect_lanes(self):
)
library.settings_dict["help_web"] = "https://google.com"
library.settings_dict["website"] = "https://google.com"
library.settings_dict["large_collection_languages"] = ["fi", "sv", "en"]
library.settings_dict["small_collection_languages"] = ["sv", "en"]
library.settings_dict["tine_collection_languages"] = ["sv", "en"]
library.is_default = True
create_default_lanes(self._db, library)

Expand All @@ -509,7 +512,17 @@ def _collect_lanes(self):
file.write("lanes = {\n")
lanes_added = []
for lane in lanes:
if not lane.display_name in lanes_added:
translate_name = not lane.display_name in lanes_added

for language in LanguageCodes.NATIVE_NAMES_RAW_DATA:
if (
lane.display_name == language["name"]
or lane.display_name == language["nativeName"]
):
translate_name = False
break

if translate_name:
file.write(
f' "{lane.display_name}": _("{lane.display_name}"),\n'
)
Expand Down
2 changes: 1 addition & 1 deletion translations/en/LC_MESSAGES/circulation-admin.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-04-24 23:41+0300\n"
"POT-Creation-Date: 2024-04-27 23:15+0300\n"
"PO-Revision-Date: 2024-02-19 22:15+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down
2 changes: 1 addition & 1 deletion translations/en/LC_MESSAGES/circulation.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-04-24 23:41+0300\n"
"POT-Creation-Date: 2024-04-27 23:15+0300\n"
"PO-Revision-Date: 2024-02-19 22:15+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down
Loading

0 comments on commit bab076a

Please sign in to comment.