Comments (8)
Numbers should be simple using http://babel.pocoo.org/en/latest/numbers.html
In [24]: format_number(14900, locale='hr')
Out[24]: '14.900'
Though it doesn't seem to work for shorter numbers:
In [31]: format_number(2, locale='hr')
Out[31]: '2'
Do you know how to localize just years (vs. full dates) using babel
or a similar python library? I tried treating the year a number (which wouldn't really expect to work) and formatting just the year using a made-up date (expecting "2019."):
In [23]: format_number(2019, locale='hr')
Out[23]: '2.019'
In [30]: format_date(datetime.date(2019,1,1), "yyyy", locale='hr')
Out[30]: '2019'
When printing dates I usually use https://en.wikipedia.org/wiki/ISO_8601 instead of localizing; at least in the USA the "normal" local format is ambiguous about month/day coming first. That standard specifies years as being printed as just 4 digits. Adding localization like a period after the year seems reasonable though.
from fatcat-scholar.
Unfortunately, I'm not a programmer, so I can't help really help in this case :-((
I don't understand why you think that it does not work for shorter numbers (it looks good to me, it's just one number which does not need a separator anyway):
In [31]: format_number(2, locale='hr')
Out[31]: '2'
from fatcat-scholar.
Shouldn't it be "2.", like we would use "Showing {num} out of {num}..." at the bottom of the page? Or maybe I am misunderstanding... is it only ordinals like "1." meaning "first"?
In the example of the bottom of the page, "Prikaz rezultata: 1. – 15. od 4,396,586", should the total be "4.396.586" or "4.396.586."? And if we had (hypothetically) paged to late results, would it be ""Prikaz rezultata: 1.000. – 1.015. od 4.396.586"?
from fatcat-scholar.
Yes, it's about ordinals. Just as dates and years, ordinals also need the period.
"Prikaz rezultata: ordinal
– ordinal
od total
"
"Prikaz rezultata: 1. – 15. od 4.396.586"
"Prikaz rezultata: 1.000. – 1.015. od 4.396.586"
Thousands separator character:
Both period
and space
are used in many languages, not just Croatian.
If space
is used as separator, it's actually better to use (in the order of my preference):
- 'NARROW NO-BREAK SPACE' (U+202F)
- 'NO-BREAK SPACE' (U+00A0)
in order to avoid breaking long numbers due to automatic line wrap and word wrap.
from fatcat-scholar.
Finally revisiting this, and maybe I understand better.
The ordinal/non-ordinal distinction can be handled in the template, as opposed to trying to get babel's number formatting routine to figure it out. But the separators (etc) are best left to babel.
For the year, I can create a template that passes the 4-digit year through with no separator, but allows locale-specific wrapping of the year string; in this case adding a period in the template.
I will try to get these changes pushed soon.
from fatcat-scholar.
Most of the numbers should be fixed now. I believe that the year display will be fixed once the translation files are pulled from weblate; i'll keep this issue open until I do that (next week?) and confirm.
from fatcat-scholar.
Pushed updates, and they look correct to me (from a brief scan). @milotype if you get a chance, please verifiy and close this issue if it looks good. I'll close some time in the next week or two if I don't hear back.
Thanks! It was good to learn how to do this correctly, and should improve localization for all users.
from fatcat-scholar.
@bnewbold Your changes look good! But I found one more instance of the issue on the homepage (https://scholar-qa.archive.org/). Please see screenshot below.
from fatcat-scholar.
Related Issues (20)
- January 2021 UI iteration bugs HOT 1
- Mangled Cyrillic full text
- External requests could be async/await HOT 1
- ES schema DOI (and other identifiers) should be case-insensitive HOT 1
- circle action buttons not always center-aligned under buttons (desktop)
- CORS not working HOT 7
- CI: add "codespell" tool
- Indexing: add field (or tag?) for preservation status
- Display volume, issue, pages HOT 3
- only highlight query string in result highlights
- More UI/UX Ideas
- better query support for exact matching
- social "cards" when sharing links
- DBLP: "of" to "&" ? HOT 1
- Generated bibliography files have incomplete author info
- i18n/hr: 'Support and Acknowledgements' paragraph on About page not displaying translation (even though translation exists) HOT 4
- search results page occasionally dumps escaped HTML for part of the page HOT 7
- PDFs with GROBID 'success' but empty GROBID fulltext body lack any access option on scholar.archive.org (eg, presentation slides) HOT 1
- API url is missing from redoc HOT 1
- Implement OAI-PMH API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fatcat-scholar.