aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fatcat_scholar/templates/search.html8
-rw-r--r--fatcat_scholar/templates/search_macros.html10
-rw-r--r--fatcat_scholar/web.py2
3 files changed, 12 insertions, 8 deletions
diff --git a/fatcat_scholar/templates/search.html b/fatcat_scholar/templates/search.html
index 2010f0e..164b7fd 100644
--- a/fatcat_scholar/templates/search.html
+++ b/fatcat_scholar/templates/search.html
@@ -43,7 +43,7 @@
</details>
{% if hits %}
- <span class="hit-count" style="font-size: 1.5em;">{{ "{:,}".format(hits.count_found) }}</span>
+ <span class="hit-count" style="font-size: 1.5em;">{{ babel_numbers.format_number(hits.count_found, locale=locale) }}</span>
{% trans trimmed count=hits.count_found %}
Hit
{% pluralize %}
@@ -72,7 +72,7 @@
{% set count_size = "2.0em" %}
{% endif %}
<span class="hit-count" style="display: block; font-size: {{ count_size }};">
- {{ "{:,}".format(hits.count_found) }}
+ {{ babel_numbers.format_number(hits.count_found, locale=locale) }}
</span>
{% trans trimmed count=hits.count_found %}
Hit
@@ -122,7 +122,7 @@
{% if hits.offset != 0 %}
<div style="margin-bottom: 2em; width: 100%;">
<div class="search-pagination">
- {{ search_macros.search_pagination(hits) }}
+ {{ search_macros.search_pagination(hits, locale=locale) }}
</div>
</div>
{% endif %}
@@ -136,7 +136,7 @@
{% if hits.count_found > hits.limit %}
<div style="margin-top: 2em; width: 100%;">
<div class="search-pagination">
- {{ search_macros.search_pagination(hits) }}
+ {{ search_macros.search_pagination(hits, locale=locale) }}
</div>
</div>
{% endif %}
diff --git a/fatcat_scholar/templates/search_macros.html b/fatcat_scholar/templates/search_macros.html
index 5038e65..57d981b 100644
--- a/fatcat_scholar/templates/search_macros.html
+++ b/fatcat_scholar/templates/search_macros.html
@@ -141,7 +141,7 @@
{% macro journal_row(biblio, paper) -%}
{# NOTE: should be able to call with paper.biblio or any paper.release[] #}
{% if biblio.release_year %}
- <span title="{{ biblio.release_date or '' }}">{{ biblio.release_year }}</span>
+ <span title="{{ biblio.release_date or '' }}">{% trans year=biblio.release_year %}{{ year }}{% endtrans %}</span>
{% endif %}
{% if biblio.container_name %}
<i {% if biblio.publisher %}title="{{ biblio.publisher }}"{% endif %}>
@@ -169,7 +169,7 @@
{% endif %}
{% endmacro %}
-{% macro fulltext_search_result_row(paper, locale=None, debug_mode=False, expand=False) -%}
+{% macro fulltext_search_result_row(paper, locale, debug_mode=False, expand=False) -%}
<div class="ui stackable doubling grid">
<div class="thirteen wide column biblio-record">
@@ -487,7 +487,7 @@
</div> {# final row close #}
{% endmacro %}
-{% macro search_pagination(hits, top) %}
+{% macro search_pagination(hits, locale) %}
{% if hits.offset > 0 %}
<button class="text-button" form="search_form" type="submit" name="offset" value="{{ hits.offset - hits.limit }}" style="float: left;" rel="prev">
<a>{% trans %}&laquo; Previous{% endtrans %}</a>
@@ -505,7 +505,9 @@
{% endif %}
<i style="padding-left: 0.5em; padding-right: 0.5em;">
- {% trans trimmed start=(hits.offset + 1), end=(hits.offset + hits.limit), total="{:,}".format(hits.count_found) %}
+ {% trans trimmed start=babel_numbers.format_number(hits.offset + 1, locale=locale),
+ end=babel_numbers.format_number(hits.offset + hits.limit, locale=locale),
+ total=babel_numbers.format_number(hits.count_found, locale=locale) %}
Showing results {{ start }} &mdash; {{ end }} out of {{ total }} results
{% endtrans %}
</i>
diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py
index 133ddce..124e269 100644
--- a/fatcat_scholar/web.py
+++ b/fatcat_scholar/web.py
@@ -8,6 +8,7 @@ import logging
from typing import Optional, Any, List, Dict
from pydantic import BaseModel
+import babel.numbers
import babel.support
from fastapi import FastAPI, APIRouter, Request, Depends, Response, HTTPException
from fastapi.staticfiles import StaticFiles
@@ -160,6 +161,7 @@ def load_i18n_templates() -> Any:
templates.env.lstrip_blocks = True
# pass-through application settings to be available in templates
templates.env.globals["settings"] = settings
+ templates.env.globals["babel_numbers"] = babel.numbers
d[lang_opt] = templates
return d