Latex Reverse RTL Page Numbers

I was compiling a book using LuaLatex only to find out that page numbers are messed up because the book's language is a right to left language.

Page 9's number is 9
Page 10's number is 01
Page 12's number is 21
and so...

Solution was to add this to reverse the numbers.


Change arabic with the language of your book :)