Skip to content

Commit

Permalink
add (partial) (be)gadke(pa)t support
Browse files Browse the repository at this point in the history
  • Loading branch information
borota committed Oct 18, 2017
1 parent b3015f3 commit 6915d68
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Following bundles are available:
libraries and applications

The package could also be downloaded directly from:
[https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.1.tgz](https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.1.tgz)
[https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.2.tgz](https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.2.tgz)

## More information

Expand Down
2 changes: 1 addition & 1 deletion doc/readme.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Following bundles are available:
libraries and applications

The package could also be downloaded directly from:
[https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.1.tgz](https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.1.tgz)
[https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.2.tgz](https://registry.npmjs.org/cal-arabic/-/cal-arabic-1.0.2.tgz)

## More information

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cal-arabic",
"version": "1.0.1",
"version": "1.0.2",
"description": "CAL Code to Arabic Unicode conversion",
"main": "build/cal-arabic.js",
"mainMin": "build/cal-arabic.min.js",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const isDev = process.env.BUILD === 'dev';
const banner = isProduction
? '/**\n' +
'* @file CAL Code to Arabic Unicode conversion\n' +
'* @version 1.0.1\n' +
'* @version 1.0.2\n' +
'* @author Greg Borota\n' +
'* @copyright (c) 2017 Greg Borota.\n' +
'* @license MIT\n' +
Expand Down
16 changes: 16 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ const damma = '\u064F'; // ُ Arabic damma - Garshuni: u
const waw = '\u0648'; // و ARABIC LETTER WAW
const yeh = '\u064A'; // ي ARABIC LETTER YEH
const madda = '\u0622'; // آ ARABIC LETTER ALEF WITH MADDA ABOVE
const ghain = '\u063A'; // غ ARABIC LETTER GHAIN
const thal = '\u0630'; // ذ ARABIC LETTER THAL
const khah = '\u062E'; // خ ARABIC LETTER KHAH
const theh = '\u062B'; // ث ARABIC LETTER THEH

/**
* @private
Expand All @@ -89,6 +93,18 @@ const mapCallback = (word, i, fromTo, wordProps) => {
let m = '';
const n = word.charAt(i + 1);
switch (c) {
case 'g':
m = n === ',' ? ghain : to(c, fromTo);
break;
case 'd':
m = n === ',' ? thal : to(c, fromTo);
break;
case 'k':
m = n === ',' ? khah : to(c, fromTo);
break;
case 't':
m = n === ',' ? theh : to(c, fromTo);
break;
case 'y':
m =
n === 'i' || n === 'e'
Expand Down
23 changes: 14 additions & 9 deletions test/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('CAL', () => {
const word = sut.toArabic('dqsry)-dpylypws');
const wordExpected = 'دقسريا-دفيليفوس';
const vocalised = sut.toArabic("d'qesariya)-d,p,yilyip'wOs");
const vocalisedExpected = 'دقِسَرِيَا-دفِيلِيفُوس';
const vocalisedExpected = 'دقِسَرِيَا-ذفِيلِيفُوس';
test.strictEqual(word, wordExpected, 'sut.toArabic_generic consonant');
test.strictEqual(
vocalised,
Expand All @@ -30,8 +30,8 @@ describe('CAL', () => {
it('Alef superscript', () => {
const word = sut.toArabic('$mk');
const wordExpected = 'شمك';
const vocalised = sut.toArabic('$mok');
const vocalisedExpected = 'شمٰك';
const vocalised = sut.toArabic('$mok,');
const vocalisedExpected = 'شمٰخ';
test.strictEqual(word, wordExpected, 'sut.toArabic_madda consonant');
test.strictEqual(
vocalised,
Expand All @@ -43,7 +43,7 @@ describe('CAL', () => {
const word = sut.toArabic('dylydwth');
const wordExpected = 'ديليدوته';
const vocalised = sut.toArabic("d'yilyid,wut,ehE");
const vocalisedExpected = 'دِيلِيدُوتِهِ';
const vocalisedExpected = 'دِيلِيذُوثِهِ';
test.strictEqual(word, wordExpected, 'sut.toArabic_yi consonant');
test.strictEqual(
vocalised,
Expand Down Expand Up @@ -112,21 +112,26 @@ describe('CAL', () => {
);
});
it('Word with Hebrew Shin', () => {
const word = sut.toArabic(')d$)');
const wordExpected = 'ادشا';
const vocalised = sut.toArabic(')od,$o)');
const vocalisedExpected = 'آدشَا';
const word = sut.toArabic(')g$)');
const wordExpected = 'اجشا';
const vocalised = sut.toArabic(')og,$o)');
const vocalisedExpected = 'آغشَا';
test.strictEqual(word, wordExpected, 'sut.toArabic consonant with Shin');
test.strictEqual(
vocalised,
vocalisedExpected,
'sut.toArabic vocalised with Shin'
);
});
it('Begadkepat', () => {
const word = sut.toArabic('begadkepat');
const wordExpected = 'بِجَدكِفَت';
test.strictEqual(word, wordExpected, 'sut.toArabic punctuation');
});
it('Punctuation', () => {
const word = sut.toArabic(';)o)ar?');
const wordExpected = '؛آاَر؟';
test.strictEqual(word, wordExpected, 'sut.toArabic invalid rukkakha');
test.strictEqual(word, wordExpected, 'sut.toArabic punctuation');
});
it('Invalid Rukkakha', () => {
const word = sut.toArabic(')Pbh,swh&');
Expand Down

0 comments on commit 6915d68

Please sign in to comment.