Skip to content

Commit

Permalink
Merge pull request #4 from yousifnimah/dev
Browse files Browse the repository at this point in the history
Fixing Thousands
  • Loading branch information
yousifnimah authored Jul 23, 2023
2 parents ca07e3a + bd75a3c commit 8242c63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 36 deletions.
45 changes: 11 additions & 34 deletions NumToWords/EntryAr.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ func (Entry *EntryAr) Translate(Input int) string {
{
Result = Entry.handleHundreds(Input)
}
case Input < 10000: //1000-9999
case Input < 1000000: //1000-9999
{
Result = Entry.handleThousands(Input)
}
case Input < 100000: //10000-99999
{
Result = Entry.handleTenThousands(Input)
}
case Input < 1000000: //100000-999999
{
Result = Entry.handleHundredsThousands(Input)
}
//case Input < 100000: //10000-99999
// {
// Result = Entry.handleTenThousands(Input)
// }
//case Input < 1000000: //100000-999999
// {
// Result = Entry.handleHundredsThousands(Input)
// }
case Input < 1000000000: //1000000-9999999
{
Result = Entry.handleMillions(Input)
Expand All @@ -52,29 +52,6 @@ func (Entry *EntryAr) Translate(Input int) string {
Result = Entry.handleBillions(Input)
}
}

//if Input < 10 {
// result = Entry.handleUnits(Input)
//} else if Input < 20 {
// result = Entry.LocalizedEntity.Teens[Input-10]
//} else if Input < 100 {
// Seg01 := Entry.Translate(Input % 10)
// Seg02 := Entry.LocalizedEntity.Tens[Input/10]
// if Seg01 != "" && Seg02 != "" {
// And = Entry.LocalizedEntity.And
// }
// result = fmt.Sprintf("%s %s %s", Seg01, And, Seg02)
//} else if Input < 1000 {
// result = fmt.Sprintf("%s %s %s", Entry.Translate(Input/100), Entry.LocalizedEntity.Hundred, Entry.Translate(Input%100))
//} else if Input < 1000000 {
// result = fmt.Sprintf("%s %s %s", Entry.Translate(Input/1000), Entry.LocalizedEntity.Thousand, Entry.Translate(Input%1000))
//} else if Input < 1000000000 {
// result = fmt.Sprintf("%s %s %s", Entry.Translate(Input/1000000), Entry.LocalizedEntity.Million, Entry.Translate(Input%1000000))
//} else if Input < 10000000000 {
// result = fmt.Sprintf("%s %s %s", Entry.Translate(Input/1000000000), Entry.LocalizedEntity.Billion, Entry.Translate(Input%1000000000))
//} else {
// result = fmt.Sprintf("%s %s %s", Entry.Translate(Input/1000000000000), Entry.LocalizedEntity.Trillion, Entry.Translate(Input%1000000000000))
//}
return strings.TrimSpace(Result)
}

Expand Down Expand Up @@ -109,12 +86,12 @@ func (EntAr EntryAr) handleHundreds(Input int) string {

func (EntAr EntryAr) handleThousands(Input int) string {
And := ""
Seg01 := EntAr.LocalizedEntity.Thousands[(Input / 1000)]
Seg01 := EntAr.Translate(Input / 1000)
Seg03 := EntAr.Translate(Input % 1000)
if Seg01 != "" && Seg03 != "" {
And = EntAr.LocalizedEntity.And
}
return fmt.Sprintf("%s %s %s", Seg01, And, Seg03)
return fmt.Sprintf("%s %s %s %s", Seg01, EntAr.LocalizedEntity.Thousand, And, Seg03)
}

func (EntAr EntryAr) handleTenThousands(Input int) string {
Expand Down
2 changes: 1 addition & 1 deletion NumToWords/locales/ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var AR = Lang{
And: "و",
Zero: "صفر",
Hundred: "مئة",
Thousand: "الف",
Thousand: "الفاً",
Million: "مليون",
Billion: "مليار",
}
2 changes: 1 addition & 1 deletion _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func main() {
input := 1000010012
input := 1155010
words, err := NumToWords.Convert(input, "ar")
if err != nil {
return
Expand Down

0 comments on commit 8242c63

Please sign in to comment.