✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Format setting for Farsi (Arabic) numbers

Hi dear Dash community,
Is there any option to show numbers in Farsi (Arabic) in a dash datatable?
I am using DataTable like below in a dbc.Container :

    dbc.Row(
            dbc.Col(
                dash_table.DataTable(  # ---------------------------------------------------------
                    id="datatable-Rates",
                    columns=[
                        dict(id=i, name=j, editable=m, type=l, format=k)
                        for i, j, k, l, m in zip(
                            Rates_columns[::-1],
                            Rates_names[::-1],
                            Rates_formats[::-1],
                            Rates_types[::-1],
                            Rates_editable[::-1],
                        )
                    ],
                    data=Rates.to_dict("records"),  # the contents of the table
                    # filter_action="native",
                    sort_action="native",
                    selected_rows=[],
                    sort_mode="single",
                    style_cell={
                        "minWidth": 35,
                        "width": 370,
                    },
                    fill_width=False,
                    style_cell_conditional=[  # align text columns to left. By default they are aligned to right
                        {"if": {"column_id": c}, "textAlign": "center"} for c in Rates.columns
                    ],
                    style_data_conditional=[  # 125, 181, 178
                        {
                            "if": {"column_editable": False},
                            "backgroundColor": cell_background_color,
                            "color": cell_background_editable,
                        }
                    ],
                    style_data={
                        "whiteSpace": "normal",
                        "height": "auto",
                        "border": "none",
                        "border-bottom": "1px solid #ccc",
                    },  
                    style_header={"backgroundColor": header_background_color, "color": "white"},
                ),
            ),
        ),

Excuse my ignorance here - from your screenshot it looks like characters are appearing.

What is broken or unexpected about what is displayed?

No problem :+1:
I just need to display numbers in Farsi.

I am not experienced, but I think people change font in css to convert number fonts.
I don’t know where I can change the font in datatable.

I see. And the data in your Rates isn’t using the Farsi number characters? So you’re looking for the DataTable to convert english/western numbers to Farsi numbers?

Yeah exactly, the numbers in Data are just float numbers.
For example How can I view Arabic/Persian numbers in a HTML page with strict doctype?

I don’t know if this is possible in Dash.

I see. Your best bet right now would probably be to replace the numbers characters in Python (in your Rates variable) before passing them up. Unfortunately there isn’t any built-in “number conversion” logic in the DataTable or in browsers (e.g. via CSS)

1 Like