Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why numbers getting reversed when formatted in RTL Arabic - Rails application?

I'm using Prawn gem in my Rails app to generate PDF reports.

I read the documentation for putting the text in Arabic with text_direction RTL in arabic.

But, issue is that numbers are getting reversed here.

I wanted semester 1234 as الفصل الدراسي 1234,

but in my app the output is الفصل الدراسي 4321.

My two lines of code is here:

pdftable = Prawn::Document.new
pdftable.text(t('org.semester') + " " + @semester)

@semester = '1234' (The reason would be that it is being treated as a text/string, thus changes to RTL (reversed))

Anyway, Please help me to retain numbers in proper order without changing the RTL format.

like image 417
Rajesh Omanakuttan Avatar asked Nov 02 '22 02:11

Rajesh Omanakuttan


1 Answers

Without hacking too much you could use

@semester.to_s.reverse

So you reverse the string twice

like image 122
Ruby Racer Avatar answered Nov 10 '22 12:11

Ruby Racer