GitHub user dosubot[bot] added a comment to the discussion: Translation of time 
passed

<!-- Answer -->
The backend receives the `/api/v1/chart/` request in the `ChartRestApi` class 
(`superset/charts/api.py`), which operates on the `Slice` model. The field 
`changed_on_delta_humanized` is generated by the `changed_on_humanized` 
property in the model mixin (`superset/models/helpers.py`). This property uses 
the Python `humanize.naturaltime` function to create human-readable time 
differences, like "2 minutes ago" or "a day ago" 
[(source)](https://github.com/apache/superset/blob/235c9d2ebf2b14af7afac854b5b15a877695d1b1/superset/models/helpers.py).

Currently, this value is always rendered in English because the `humanize` 
library does not support localization out-of-the-box, and Superset does not add 
any translation layer for this field on the backend. Even though Flask-Babel is 
available in Superset, it is not used for these relative time strings.

To translate `changed_on_delta_humanized`, you would need to replace or wrap 
the `humanize.naturaltime` call with a localization-aware solution, such as 
using Flask-Babel's `format_timedelta` or another library that supports your 
target language. This would require a code change in the backend where 
`changed_on_humanized` is defined.

Let me know if you want more details on how to implement this.


<!-- Dosu Comment Footer -->
*To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/0cddda57-7372-4d96-8f8d-d50d074cf6fe?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/0cddda57-7372-4d96-8f8d-d50d074cf6fe?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/0cddda57-7372-4d96-8f8d-d50d074cf6fe?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/0cddda57-7372-4d96-8f8d-d50d074cf6fe?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/0cddda57-7372-4d96-8f8d-d50d074cf6fe?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/0cddda57-7372-4d96-8f8d-d50d074cf6fe?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/0cddda57-7372-4d96-8f8d-d50d074cf6fe?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Sh
 are on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/33630)

GitHub link: 
https://github.com/apache/superset/discussions/33630#discussioncomment-13321807

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to