js-written-number icon indicating copy to clipboard operation
js-written-number copied to clipboard

Adding Persian

Open hosein2398 opened this issue 6 years ago • 1 comments

Hi guys, I was trying to add Persian(Farsi) for this library that I faced some problems , thought it's good to share them here so that I can figure out that do you have any solution for them or not. First of all this is the json file I've created:


{ "useLongScale": false, "baseSeparator": " و ", "base": { "0": "صفر", "1": "یک", "2": "دو", "3": "سه", "4": "چهار", "5": "پنج", "6": "شش", "7": "هفت", "8": "هشت", "9": "نه", "10": "ده", "11": "یازده", "12": "دوازده", "13": "سیزده", "14": "چهارده", "15": "پانزده", "16": "شانزده", "17": "هفده", "18": "هجده", "19": "نوزده", "20": "یست", "30": "سی", "40": "چهل", "50": "پنجاه", "60": "شصت", "70": "هفتاد", "80": "هشتاد", "90": "نود", "100": "صد", "200": "دویست", "300":"سی صد ", "500":"پانصد صد ", ... }, "units": [ "صد", "هزار", "میلیون", "بیلیون" ], "unitExceptions": [ ] }


I was testing some random numbers like: writtenNumber(1234, { lang: 'fa' }) // یک هزار دو صد و سی و چهار

This one has two issues .

1. In Persian we have exception for numbers 200 , 300 , 500, that they can not be made out of just mixing the number + the word "hundred" like: 2(two) + hundred or like 5(five) + hundred , they are special , but about others we can do such a think, like for 800 all we have to do is to mix the word "هشت" (or "eight" in English) with "صد" which stands for hundred. So please help me resolve this ,how can I write some conditional statements for 200 , 300 , 500 What's the solution?

2. Second one is Separator issue , in Persian after every number we should have that Separator. But in this example after first number which is "یک هزار" (meaning one thousand) we don't see the Separator " و " even though after this first number that's OK and we see the Separator after every number which are that bold ones below and that italic one is actually the missing one which I described about: یک هزار و دو صد و سی و چهار How can I resolve this one too?

Thanks

hosein2398 avatar Jul 09 '17 12:07 hosein2398

This should be similar to arabic. I am waiting for pull request https://github.com/yamadapc/js-written-number/pull/52 to be accepted, and I will have a look to persian.

forzagreen avatar Feb 16 '18 10:02 forzagreen