Skip to content

Commit

Permalink
Update i18n exclude list and add remaining exceptions where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rebecca-shoptaw committed Jul 1, 2024
1 parent 5ae246f commit b8ba05e
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 71 deletions.
45 changes: 34 additions & 11 deletions openlibrary/i18n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -473,22 +473,24 @@ msgid "Server status"
msgstr ""

#: SearchNavigation.html SubjectTags.html lib/nav_foot.html lib/nav_head.html
#: subjects.html subjects/notfound.html type/author/view.html
#: type/list/view_body.html work_search.html
#: search/work_search_facets.html subjects.html subjects/notfound.html
#: type/author/view.html type/list/view_body.html work_search.html
msgid "Subjects"
msgstr ""

#: SubjectTags.html subjects.html type/author/view.html
#: type/list/view_body.html work_search.html
#: SubjectTags.html search/work_search_facets.html subjects.html
#: type/author/view.html type/list/view_body.html work_search.html
msgid "Places"
msgstr ""

#: SubjectTags.html admin/menu.html subjects.html type/author/view.html
#: type/list/view_body.html work_search.html
#: SubjectTags.html admin/menu.html search/work_search_facets.html
#: subjects.html type/author/view.html type/list/view_body.html
#: work_search.html
msgid "People"
msgstr ""

#: SubjectTags.html subjects.html type/list/view_body.html work_search.html
#: SubjectTags.html search/work_search_facets.html subjects.html
#: type/list/view_body.html work_search.html
msgid "Times"
msgstr ""

Expand Down Expand Up @@ -783,21 +785,22 @@ msgstr ""
msgid "eBook?"
msgstr ""

#: type/edition/view.html type/work/view.html work_search.html
#: search/work_search_facets.html type/edition/view.html type/work/view.html
#: work_search.html
msgid "Language"
msgstr ""

#: books/add.html books/edit.html books/edit/edition.html lib/nav_head.html
#: search/advancedsearch.html work_search.html
#: search/advancedsearch.html search/work_search_facets.html work_search.html
msgid "Author"
msgstr ""

#: work_search.html
msgid "First published"
msgstr ""

#: search/advancedsearch.html type/edition/view.html type/work/view.html
#: work_search.html
#: search/advancedsearch.html search/work_search_facets.html
#: type/edition/view.html type/work/view.html work_search.html
msgid "Publisher"
msgstr ""

Expand Down Expand Up @@ -5162,6 +5165,14 @@ msgstr ""
msgid "work"
msgstr ""

#: search/work_search_facets.html
msgid "Ebook"
msgstr ""

#: search/work_search_facets.html
msgid "FirstPublished"
msgstr ""

#: search/work_search_facets.html
msgid "Merge duplicate authors from this search"
msgstr ""
Expand Down Expand Up @@ -5690,6 +5701,14 @@ msgstr ""
msgid "Loading Related Books"
msgstr ""

#: type/i18n_page/edit.html
msgid "Available Translations:"
msgstr ""

#: type/i18n_page/edit.html
msgid "Please select one ..."
msgstr ""

#: type/language/view.html
msgid "Code"
msgstr ""
Expand Down Expand Up @@ -6499,6 +6518,10 @@ msgstr ""
msgid "Check WorldCat for an edition near you"
msgstr ""

#: WorldcatLink.html
msgid "WorldCat"
msgstr ""

#: databarDiff.html databarEdit.html
msgid "View the editing history of this page"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions openlibrary/macros/IABook.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h3 itemprop="name" class="booktitle">
</h3>
</div>
</div>
$# detect-missing-i18n-skip-line
$# The following (empty) <div> is to aid in formatting the layout.
<div class="searchResultItemCTA">
</div>
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/macros/TableOfContents.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
$if label and not label.endswith('.'):
$ label = label.strip() + '. '
$if highlighting:
$# This isn't html injection, because solr returns everything
$# already html escaped except for the <em> of the highlight
$# detect-missing-i18n-skip-line
$# This isn't html injection, because solr returns everything already html escaped except for the <em> of the highlight
$:label
$:chapter.title
$else:
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/macros/WorldcatLink.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p class="cta-section-title world-cat-link">$_("Check nearby libraries")</p>
<ul class="book-locate-options">
$if isbn:
<li><a href="https://labs.library.link/services/borrow/?isbn=$isbn&embed=True&radius=500&refer=$(referer)">Library.link</a></li>
<li><a class="worldcat-link" data-ol-link-track="worldcat-search" href="$macros.WorldcatUrl(isbn=isbn, oclc_numbers=oclc_numbers)" title="$_('Check WorldCat for an edition near you')">WorldCat</a></li>
<li><a href="https://labs.library.link/services/borrow/?isbn=$isbn&embed=True&radius=500&refer=$(referer)">$('Library.link')</a></li>
<li><a class="worldcat-link" data-ol-link-track="worldcat-search" href="$macros.WorldcatUrl(isbn=isbn, oclc_numbers=oclc_numbers)" title="$_('Check WorldCat for an edition near you')">$_("WorldCat")</a></li>
</ul>
</div>
2 changes: 1 addition & 1 deletion openlibrary/templates/covers/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$elif status.code == 3: $_("Please provide a valid image.")
</div>

<div class="imageIntro">$intro $:_('Learn more by reading our <a href="/help/faq/editing#picture" target="blank">%(guidelines)s</a>.', guidelines=guideline)</div>
<div class="imageIntro">$intro <span>$:_('Learn more by reading our <a href="/help/faq/editing#picture" target="blank">%(guidelines)s</a>.', guidelines=guideline)</span></div>
$if doc.type.key == "/type/work":
$if doc.get_edition_covers():
<form class="ol-cover-form ol-cover-form--id" method="post" enctype="multipart/form-data" action="$action">
Expand Down
26 changes: 13 additions & 13 deletions openlibrary/templates/languages/language_list.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
$def with (classes='')

<ul class="locale-options $classes">
<li><a href="#" lang="cs" data-lang-id="cs" title="$_('Czech')">Čeština (cs)</a></li>
<li><a href="#" lang="de" data-lang-id="de" title="$_('German')">Deutsch (de)</a></li>
<li><a href="#" lang="en" data-lang-id="en" title="$_('English')">English (en)</a></li>
<li><a href="#" lang="es" data-lang-id="es" title="$_('Spanish')">Español (es)</a></li>
<li><a href="#" lang="fr" data-lang-id="fr" title="$_('French')">Français (fr)</a></li>
<li><a href="#" lang="hr" data-lang-id="hr" title="$_('Croatian')">Hrvatski (hr)</a></li>
<li><a href="#" lang="it" data-lang-id="it" title="$_('Italian')">Italiano (it)</a></li>
<li><a href="#" lang="pt" data-lang-id="pt" title="$_('Portuguese')">Português (pt)</a></li>
<li><a href="#" lang="hi" data-lang-id="hi" title="$_('Hindi')">हिंदी (hi)</a></li>
<li><a href="#" lang="sc" data-lang-id="sc" title="$_('Sardinian')">Sardu (sc)</a></li>
<li><a href="#" lang="te" data-lang-id="te" title="$_('Telugu')">తెలుగు (te)</a></li>
<li><a href="#" lang="uk" data-lang-id="uk" title="$_('Ukrainian')">Українська (uk)</a></li>
<li><a href="#" lang="zh" data-lang-id="zh" title="$_('Chinese')">中文 (zh)</a></li>
<li><a href="#" lang="cs" data-lang-id="cs" title="$_('Czech')">$("Čeština (cs)")</a></li>
<li><a href="#" lang="de" data-lang-id="de" title="$_('German')">$("Deutsch (de)")</a></li>
<li><a href="#" lang="en" data-lang-id="en" title="$_('English')">$("English (en)")</a></li>
<li><a href="#" lang="es" data-lang-id="es" title="$_('Spanish')">$("Español (es)")</a></li>
<li><a href="#" lang="fr" data-lang-id="fr" title="$_('French')">$("Français (fr)")</a></li>
<li><a href="#" lang="hr" data-lang-id="hr" title="$_('Croatian')">$("Hrvatski (hr)")</a></li>
<li><a href="#" lang="it" data-lang-id="it" title="$_('Italian')">$("Italiano (it)")</a></li>
<li><a href="#" lang="pt" data-lang-id="pt" title="$_('Portuguese')">$("Português (pt)")</a></li>
<li><a href="#" lang="hi" data-lang-id="hi" title="$_('Hindi')">$("हिंदी (hi)")</a></li>
<li><a href="#" lang="sc" data-lang-id="sc" title="$_('Sardinian')">$("Sardu (sc)")</a></li>
<li><a href="#" lang="te" data-lang-id="te" title="$_('Telugu')">$("తెలుగు (te)")</a></li>
<li><a href="#" lang="uk" data-lang-id="uk" title="$_('Ukrainian')">$("Українська (uk)")</a></li>
<li><a href="#" lang="zh" data-lang-id="zh" title="$_('Chinese')">$("中文 (zh)")</a></li>
</ul>
18 changes: 9 additions & 9 deletions openlibrary/templates/search/work_search_facets.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
KeyError will be raised if key is not in the following dict.
"""
facets = {
"has_fulltext": "Ebook",
"author_key": "Author",
"subject_facet": "Subjects",
"person_facet": "People",
"place_facet": "Places",
"time_facet": "Times",
"first_publish_year": "FirstPublished",
"publisher_facet": "Publisher",
"language": "Language",
"has_fulltext": _("Ebook"),
"author_key": _("Author"),
"subject_facet": _("Subjects"),
"person_facet": _("People"),
"place_facet": _("Places"),
"time_facet": _("Times"),
"first_publish_year": _("FirstPublished"),
"publisher_facet": _("Publisher"),
"language": _("Language"),
}
return "SearchFacet|" + facets[key]

Expand Down
4 changes: 1 addition & 3 deletions openlibrary/templates/subjects.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ <h2 class="inline">

<div class="head" id="subjectRelated">
<h2>$_("Related...")
<!--
<span class="count"><a href="/search?${page.subject_type}_facet=$page.name.replace('&','%26')">Search within $page.name</a></span>
-->
<!-- <span class="count"><a href="/search?${page.subject_type}_facet=$page.name.replace('&','%26')">Search within $page.name</a></span> -->
</h2>
</div>

Expand Down
12 changes: 6 additions & 6 deletions openlibrary/templates/type/i18n_page/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ <h1>$page.key</h1>
<div id="contentBody">
$:macros.TypeChanger(page.type)
<div class="formElement">
<div class="label"><label for="_lang">Available Translations:</label></div>
<div class="label"><label for="_lang">$_("Available Translations:")</label></div>
<div class="input">
<select name="_lang" onchange="window.location = (window.location.protocol + '//' + window.location.host + this.options[this.selectedIndex].value + window.location.search + '&redirect=$page.key')" id="lang_dropdown">
<option value="">Please select one ...</option>
<option value="${key}.en">English (en)</option>
<option value="${key}.it">Italian (it)</option>
<option value="${key}.es">Spanish (es)</option>
<option value="${key}.te">Telugu (te)</option>
<option value="">$_("Please select one ...")</option>
<option value="${key}.en">$('English (en)')</option>
<option value="${key}.it">$('Italian (it)')</option>
<option value="${key}.es">$('Spanish (es)')</option>
<option value="${key}.te">$('Telugu (te)')</option>
</select>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions openlibrary/templates/type/work/editions_datatable.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@
<!-- Admin only text doesn't need to be translated -->
$if ctx.user and ctx.user.is_admin() and query_param('debug'):
<div class="clearfix"></div>
$# detect-missing-i18n-skip-line
<div class="small sansserif"><span class="adminOnly">Getting list of editions took $("%.2f" % edition_list_secs) seconds</span></div>
32 changes: 8 additions & 24 deletions scripts/detect_missing_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,25 @@
# This is a list of files that had pre-existing i18n errors/warnings at the time this script was created.
# Chip away at these and remove them from the exclude list (except where otherwise noted).
EXCLUDE_LIST = {
"openlibrary/admin/templates/admin/index.html",
"openlibrary/templates/design.html",
"openlibrary/templates/diff.html",
"openlibrary/templates/internalerror.html",
"openlibrary/templates/login.html",
"openlibrary/templates/permission_denied.html",
"openlibrary/templates/showmarc.html",
"openlibrary/templates/status.html",
"openlibrary/templates/work_search.html",
"openlibrary/templates/showia.html",
"openlibrary/templates/subjects.html",
"openlibrary/templates/about/index.html",
"openlibrary/templates/account/create.html",
"openlibrary/templates/account/import.html",
"openlibrary/templates/account/readinglog_stats.html",
"openlibrary/templates/account/email/forgot.html",
"openlibrary/templates/account/sidebar.html",
"openlibrary/templates/admin/attach_debugger.html",
"openlibrary/templates/admin/block.html",
"openlibrary/templates/admin/graphs.html",
"openlibrary/templates/admin/history.html",
"openlibrary/templates/admin/imports.html",
"openlibrary/templates/admin/imports_by_date.html",
"openlibrary/templates/admin/index.html",
"openlibrary/templates/admin/imports_by_date.html",
"openlibrary/templates/admin/loans.html",
"openlibrary/templates/admin/loans_table.html",
"openlibrary/templates/admin/solr.html",
Expand All @@ -50,29 +45,22 @@
"openlibrary/templates/admin/people/view.html",
"openlibrary/templates/books/add.html",
"openlibrary/templates/books/custom_carousel.html",
"openlibrary/templates/books/edit.html",
"openlibrary/templates/books/mobile_carousel.html",
"openlibrary/templates/books/works-show.html",
"openlibrary/templates/books/edit/edition.html",
"openlibrary/templates/books/edit/web.html",
"openlibrary/templates/check_ins/check_in_form.html",
"openlibrary/templates/contact/spam/sent.html",
"openlibrary/templates/covers/add.html",
"openlibrary/templates/email/case_created.html",
"openlibrary/templates/history/sources.html",
"openlibrary/templates/home/loans.html",
"openlibrary/templates/home/popular.html",
"openlibrary/templates/home/returncart.html",
"openlibrary/templates/jsdef/LazyAuthorPreview.html",
"openlibrary/templates/jsdef/LazyWorkPreview.html",
"openlibrary/templates/languages/index.html",
"openlibrary/templates/languages/language_list.html",
"openlibrary/templates/lib/history.html",
"openlibrary/templates/lib/header_dropdown.html",
"openlibrary/templates/lib/nav_foot.html",
"openlibrary/templates/lists/export_as_html.html",
"openlibrary/templates/lists/feed_updates.html",
"openlibrary/templates/lists/list_overview.html",
"openlibrary/templates/lists/widget.html",
"openlibrary/templates/my_books/dropdown_content.html",
"openlibrary/templates/my_books/primary_action.html",
Expand All @@ -88,41 +76,37 @@
"openlibrary/templates/recentchanges/merge/path.html",
"openlibrary/templates/recentchanges/undo/view.html",
"openlibrary/templates/search/snippets.html",
"openlibrary/templates/search/work_search_facets.html",
"openlibrary/templates/site/alert.html",
"openlibrary/templates/site/stats.html",
"openlibrary/templates/type/about/view.html",
"openlibrary/templates/type/author/rdf.html",
"openlibrary/templates/type/author/view.html",
"openlibrary/templates/type/edition/view.html",
"openlibrary/templates/type/i18n_page/edit.html",
"openlibrary/templates/type/language/view.html",
"openlibrary/templates/type/list/edit.html",
"openlibrary/templates/type/list/exports.html",
"openlibrary/templates/type/local_id/view.html",
"openlibrary/templates/type/object/view.html",
"openlibrary/templates/type/page/view.html",
"openlibrary/templates/type/template/edit.html",
"openlibrary/templates/type/template/view.html",
"openlibrary/templates/type/type/view.html",
"openlibrary/templates/type/work/editions_datatable.html",
"openlibrary/templates/type/work/view.html",
"openlibrary/macros/databarView.html",
"openlibrary/macros/DisplayCode.html",
"openlibrary/macros/FulltextSnippet.html",
"openlibrary/macros/IABook.html",
"openlibrary/macros/ManageLoansButtons.html",
"openlibrary/macros/ManageWaitlistButton.html",
"openlibrary/macros/NotesModal.html",
"openlibrary/macros/Profile.html",
"openlibrary/macros/QueryCarousel.html",
"openlibrary/macros/RecentChangesAdmin.html",
"openlibrary/macros/RecentChangesUsers.html",
"openlibrary/macros/SearchResults.html",
"openlibrary/macros/TableOfContents.html",
"openlibrary/macros/WorldcatLink.html",
"openlibrary/macros/databarWork.html",
"openlibrary/macros/WorkInfo.html",
# These are excluded because they require more info to fix
"openlibrary/templates/books/edit.html",
"openlibrary/templates/history/sources.html",
# This can't be fixed because it's not in the i18n directories
"openlibrary/admin/templates/admin/index.html",
# These can't be fixed since they're rendered as static html
"static/offline.html",
"static/status-500.html",
Expand Down Expand Up @@ -166,7 +150,7 @@ class Errtype(str, Enum):
)

i18n_element_missing_regex = opening_tag_syntax + ignore_after_opening_tag
i18n_element_warn_regex = opening_tag_syntax + r"\$\((?!_\()"
i18n_element_warn_regex = opening_tag_syntax + r"\$\(['\"]"

attr_syntax = r"(title|placeholder|alt)="
ignore_double_quote = (
Expand Down Expand Up @@ -197,7 +181,7 @@ class Errtype(str, Enum):
+ ignore_single_quote
+ r")[^>]*?>"
)
i18n_attr_warn_regex = opening_tag_open + attr_syntax + r"['\"]\$\((?!_\()"
i18n_attr_warn_regex = opening_tag_open + attr_syntax + r"\"\$\(\'"


def terminal_underline(text: str) -> str:
Expand Down

0 comments on commit b8ba05e

Please sign in to comment.