question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I can see that your library supports some localization via separator, symbols and fullforms. I guess, for Russian it would be something like:

filesize(..., {
  separator: ',',
  symbols: {
    B: "Б",
    KB: "кБ",
    MB: "мБ",
    ...
  },
  fullforms: [
    '',
    'кило',
    'мега',
    ...
  ]
})

You could make a directory called locales where people could submit pull requests with their languages.

import ru from 'filesize/locales/ru'
filesize(..., { locale: ru })

A similar API: https://github.com/sindresorhus/pretty-bytes#readme

// Localized output using German locale
prettyBytes(1337, {locale: 'de'});
//=> '1,34 kB'

Notice how they also use , in that example. That’s because they use number.toLocaleString() instead of separator. They should have also checked for number.toLocaleString existence before using it and then fall back to a default separator. They also don’t have kB translated.

These are localization API ideas you might want to review in some future if you decide on adding localization to this library. I don’t need localization, I’m using en-US.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
catamphetaminecommented, Feb 13, 2019

I don’t care about what you care and don’t care. You’re a low-skill develoepr.

1reaction
avoidworkcommented, Feb 13, 2019

i don’t care if my code breaks in a deprecated browser that only runs in an OS that’s 10+ years out dated. I just don’t care. I don’t care if you want this feature to work on modern browsers and netscape 1.0.

You’re not paying me money, so I don’t care.

Read more comments on GitHub >

github_iconTop Results From Across the Web

REST API for Localization | SimpleLocalize
SimpleLocalize offers a REST API for localization to keep your content in multiple languages and various ways to integrate it with your application....
Read more >
Localization API overview - Drupal
Localization API overview ... Drupal makes it easy to develop translatable interfaces by offering a few simple functions for writing a module's ...
Read more >
Localization for REST APIs - Stack Overflow
I am starting this discussion to gather more info on localization practices for APIs. It seems HTTP does NOT provide sufficient guidance and ......
Read more >
How to localize your API - API UX
Specifying localization parameters can be done via HTTP headers, query string, or potentially in content. Query string approaches are ...
Read more >
Localization and Translations API - Sitefinity CMS Development
Localization and Translations API. Sitefinity CMS enables you, as content creator, to localize your site in as many language versions as required.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found