Skip to content

Commit

Permalink
Handling of л and е, ё, ю, я after it
Browse files Browse the repository at this point in the history
  • Loading branch information
skip405 committed May 4, 2023
1 parent 758d2d7 commit 4c6e11d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const processSpecialCase = (char, nextChar, prevChar, style, replacement) => {
index = 0;
}
} else if( 'lacinka' === style ) {
if( ['е', 'ё', 'ю', 'я', 'ь'].includes(nextChar.toLowerCase()) ) {
if( ['е', 'ё', 'і', 'л', 'ю', 'я', 'ь'].includes(nextChar.toLowerCase()) ) {

This comment has been minimized.

Copy link
@b83

b83 May 4, 2023

А тут мусіць быць "л" таксама ў спісе?

This comment has been minimized.

Copy link
@skip405

skip405 May 4, 2023

Author Owner

Так, напрыклад наваколле канверцілась у navakołlie, а павінна быць navakolle

This comment has been minimized.

Copy link
@b83

b83 May 4, 2023

Супер!

This comment has been minimized.

Copy link
@b83

b83 May 4, 2023

А слова накшталт "сёння" мусіць быць пераўтворана ў siońnia? Я не ўпэўнены, толькі пытаю.

This comment has been minimized.

Copy link
@skip405

skip405 May 4, 2023

Author Owner

Згодна з правіламі, па якім я рабіў, ń атрымоўваецца толькі перад ь, таму сёньня будзе siońnia а сёння - sionnia.

index = 0;
} else {
index = 1;
Expand All @@ -32,6 +32,8 @@ const processSpecialCase = (char, nextChar, prevChar, style, replacement) => {
case 'я' :
if( ['а', 'і', 'о', 'у', 'ы', 'ў', 'э', 'ь', '’', '‘'].includes(prevChar.toLowerCase()) || '' === prevChar ) {
index = 1;
} else if( ['л'].includes(prevChar.toLowerCase()) && 'lacinka' === style ) {
index = 2;
}

break;
Expand Down Expand Up @@ -112,8 +114,8 @@ export default function belLat(string, options) {
['г', ['h', 'g']],
['ґ', ['g']],
['д', ['d']],
['е', ['ie', 'je']],
['ё', ['io', 'jo']],
['е', ['ie', 'je', 'e']],
['ё', ['io', 'jo', 'o']],
['ж', ['z', 'ž', 'zh']],
['з', ['z', 'ź']],
['і', ['i']],
Expand All @@ -137,8 +139,8 @@ export default function belLat(string, options) {
['ь', '_omitted'],
['ы', ['y']],
['э', ['e']],
['ю', ['iu', 'ju']],
['я', ['ia', 'ja']],
['ю', ['iu', 'ju', 'u']],
['я', ['ia', 'ja', 'a']],
['’', '_omitted'],
['‘', '_omitted'],
...options.customReplacements
Expand Down
22 changes: 13 additions & 9 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,22 @@ describe('Special cases', () => {
expect(belLat("Л", { style: 'lacinka' })).toBe("Ł");
});

test('Renders without a dash sign before Е, Ё, Ю, Я, Ь', () => {
expect(belLat("ле", { style: 'lacinka' })).toBe("lie");
expect(belLat("лё", { style: 'lacinka' })).toBe("lio");
expect(belLat("лю", { style: 'lacinka' })).toBe("liu");
expect(belLat("ля", { style: 'lacinka' })).toBe("lia");
test('Renders without a dash sign before Е, Ё, Ю, І, Л, Я, Ь', () => {
expect(belLat("ле", { style: 'lacinka' })).toBe("le");
expect(belLat("лё", { style: 'lacinka' })).toBe("lo");
expect(belLat("лю", { style: 'lacinka' })).toBe("lu");
expect(belLat("ля", { style: 'lacinka' })).toBe("la");
expect(belLat("ль", { style: 'lacinka' })).toBe("l");
expect(belLat("лі", { style: 'lacinka' })).toBe("li");
expect(belLat("лле", { style: 'lacinka' })).toBe("lle");

expect(belLat("Ле", { style: 'lacinka' })).toBe("Lie");
expect(belLat("Лё", { style: 'lacinka' })).toBe("Lio");
expect(belLat("Лю", { style: 'lacinka' })).toBe("Liu");
expect(belLat("Ля", { style: 'lacinka' })).toBe("Lia");
expect(belLat("Ле", { style: 'lacinka' })).toBe("Le");
expect(belLat("Лё", { style: 'lacinka' })).toBe("Lo");
expect(belLat("Лю", { style: 'lacinka' })).toBe("Lu");
expect(belLat("Ля", { style: 'lacinka' })).toBe("La");
expect(belLat("Ль", { style: 'lacinka' })).toBe("L");
expect(belLat("Лі", { style: 'lacinka' })).toBe("Li");
expect(belLat("Лле", { style: 'lacinka' })).toBe("Lle");
});
});
});
Expand Down

0 comments on commit 4c6e11d

Please sign in to comment.