Giter Club home page Giter Club logo

Comments (8)

bnewbold avatar bnewbold commented on July 25, 2024

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.

milotype avatar milotype commented on July 25, 2024

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.

bnewbold avatar bnewbold commented on July 25, 2024

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.

milotype avatar milotype commented on July 25, 2024

Yes, it's about ordinals. Just as dates and years, ordinals also need the period.

"Prikaz rezultata: ordinalordinal 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.

bnewbold avatar bnewbold commented on July 25, 2024

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.

bnewbold avatar bnewbold commented on July 25, 2024

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.

bnewbold avatar bnewbold commented on July 25, 2024

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.

milotype avatar milotype commented on July 25, 2024

@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.

Slika zaslona 2021-01-30 u 13 43 03

from fatcat-scholar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.