Skip to content

Commit

Permalink
Merge pull request #1 from nekoedges/meester
Browse files Browse the repository at this point in the history
feat: Added Russian substitution
  • Loading branch information
einar-hjortdal committed Dec 7, 2024
1 parent 0ea5e9b commit da55deb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions slugify_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ fn test_slugify_make_lang() {
assert slugifier.make('Har du røykt sokka dine?') == 'har-du-roeykt-sokka-dine'
slugifier.lang = Language.it
assert slugifier.make('Un € o un $') == 'un-eur-o-un'
slugifier.lang = Language.ru
assert slugifier.make('любя съешь щипцы вздохнёт мэр кайф жгуч') == 'lyubya-sesh-schiptsi-vzdohnyot-mer-kayf-zhguch'
}

fn test_max_length() {
Expand Down
49 changes: 49 additions & 0 deletions substitutions.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub enum Language {
it
nl
no
ru
}

const (

Check warning on line 14 in substitutions.v

View workflow job for this annotation

GitHub Actions / run

const () groups will be an error after 2025-01-01 (`v fmt -w source.v` will fix that for you)

Check warning on line 14 in substitutions.v

View workflow job for this annotation

GitHub Actions / run

const () groups will be an error after 2025-01-01 (`v fmt -w source.v` will fix that for you)
Expand All @@ -18,6 +19,7 @@ const (
Language.it: it_sub
Language.nl: nl_sub
Language.no: no_sub
Language.ru: ru_sub
}
// en_sub are the default and fallback substitution mappings.
// When passing a different language to `make_lang`, any mapping found in the passed language will
Expand Down Expand Up @@ -97,4 +99,51 @@ const (
'Ø': 'Oe'
'Å': 'Aa'
}
ru_sub = {
'а': 'a'
'б': 'b'
'в': 'v'
'г': 'g'
'д': 'd'
'е': 'e'
'ё': 'yo'
'ж': 'zh'
'з': 'z'
'дж': 'j'
'и': 'i'
'й': 'y'
'к': 'k'
'л': 'l'
'м': 'm'
'н': 'n'
'о': 'o'
'п': 'p'
'р': 'r'
'с': 's'
'т': 't'
'у': 'u'
'ф': 'f'
'х': 'h'
'ц': 'ts'
'ч': 'ch'
'ш': 'sh'
'щ': 'sch'
'ъ': ''
'ы': 'i'
'ь': ''
'э': 'e'
'ю': 'yu'
'я': 'ya'
'%': 'procent'
'♥': 'serdtse'
'&': 'i'
'@': 'sobaka'
'#': 'reshyotka'
'=': 'ravno'
'~': 'tilda'
'<': 'menshe'
'>': 'bolshe'
'|': 'ili'
'∞': 'beskonechnost'
}
)

0 comments on commit da55deb

Please sign in to comment.