最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

d3.js - How to localize D3 SI suffixes in Apache Superset number formatting (e.g., k, M, B → тыс., млн, млрд)? - Stack Overflow

matteradmin6PV0评论

I've been trying to localize default number formatting in Apache Superset charts, specifically the SI suffixes used in formats like .2s. Out of the box, Superset uses D3 defaults — k, M, B — but I need to show them in Russian: тыс., млн, млрд. What I’ve tried so far:

Changing Babel locale — partially localizes the interface, but does not affect number formatting.

Edited this file:

superset-frontend/node_modules/@superset-ui/core/src/number-format/factories/createD3NumberFormatter.ts

Injected a wrapper around .2s using .replace('k', ' тыс.'), etc.

Ran npm run build

Rebuilt with docker-compose -f docker-compose-non-dev.yml up -d --build

No effect in the UI, even on new charts

Tried registering a custom formatter in setupFormatters.ts:

getNumberFormatterRegistry().registerValue('RU_SHORT', d3Format('.2s'))

But Superset throws:
430227735890.2086 (Invalid format: RU_SHORT)

I also reviewed this article: Unfortunately, it doesn’t address SI suffix localization at all.

What I’m looking for:

Is there an official or stable way to override or localize SI suffixes in Superset?

Where is the correct hook — D3, @superset-ui/core, registry patching?

Has anyone successfully implemented localized short formats like .2s → 5 тыс., 20 млн, 8.3 млрд?

Any guidance, examples, or community experience would be appreciated

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far