Skip to content

Commit

Permalink
Merge pull request #1170 from nyaruka/eastern_arabic_digits
Browse files Browse the repository at this point in the history
Make numerical router tests work with Eastern Arabic digits
  • Loading branch information
rowanseymour authored Aug 7, 2023
2 parents fdf7607 + 60897fc commit 208b1a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion flows/routers/cases/tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ var testTests = []struct {
{"has_number", []types.XValue{xs("hi.51")}, result(xn("51"))},
{"has_number", []types.XValue{xs("hi .51")}, result(xn("0.51"))},
{"has_number", []types.XValue{xs(".51")}, result(xn("0.51"))},
{"has_number", []types.XValue{xs("١٢٣٤")}, result(xn("1234"))},
{"has_number", []types.XValue{xs("١٢٣٤")}, result(xn("1234"))}, // Arabic
{"has_number", []types.XValue{xs("۱۲۳۴")}, result(xn("1234"))}, // Eastern Arabic
{"has_number", []types.XValue{xs("٠.٥")}, result(xn("0.5"))},
{"has_number", []types.XValue{xs("nothing here")}, falseResult},
{"has_number", []types.XValue{xs("lOO")}, falseResult}, // no longer do substitutions
Expand Down
14 changes: 13 additions & 1 deletion flows/routers/cases/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var altNumerals = map[rune]rune{
// Eastern Arabic
// Arabic-Indic digits
'٠': '0',
'١': '1',
'٢': '2',
Expand All @@ -21,6 +21,18 @@ var altNumerals = map[rune]rune{
'٨': '8',
'٩': '9',

// Eastern Arabic-Indic digits (Persian and Urdu)
'۰': '0',
'۱': '1',
'۲': '2',
'۳': '3',
'۴': '4',
'۵': '5',
'۶': '6',
'۷': '7',
'۸': '8',
'۹': '9',

// Bengali
'০': '0',
'১': '1',
Expand Down

0 comments on commit 208b1a8

Please sign in to comment.