Is there any way to auto numbering table data with local or custom language. I’m a Bengali, I know how to auto numbering table each row 1st data using css and js. But I don’t know how to use custom number, e.g. Bangla or Arabic.
Look at my code:
<table border="1">
<tr>
<td>blue</td>
</tr>
<tr>
<td>red</td>
</tr>
<tr>
<td>black</td>
</tr>
</table>
I want something like that;
১. Apple
২. Banana
৩. Orange
৪. Strawberry
How can I get that using Javascript / jquery.. Without adding any third party plugin.
2
Answers
You need to use
toLocaleString()
method orIntl.NumberFormat()
constructor with the locale language as a parameter.For example.
num.toLocaleString('ar-EG')
.num.toLocaleString('bn-BD')
A CSS only solution would be using the CSS
counter(..)
function and pass the counter-style parameter (list-style-type
) for ‘bengali’.E.g.
td::before { content: counter(some-counter, bengali) }
Reference: MDN: counter() and MDN: list-style-type