// ***************************************************************************/
// *   Mongolian (Khalkha Cyrillic) spelling-to-phoneme rules  mn_rules      *
// *   Original Author Battseren Badral 15-05-2025                           *
// *   Contact info: bbattseren88@gmail.com                                  *
// ***************************************************************************/
// *   This program is free software; you can redistribute it and/or modify  *
// *   it under the terms of the GNU General Public License as published by  *
// *   the Free Software Foundation; either version 3 of the License, or     *
// *   (at your option) any later version.                                   *
// *                                                                         *
// *   This program is distributed in the hope that it will be useful,       *
// *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
// *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
// *   GNU General Public License for more details.                          *
// *                                                                         *
// *   You should have received a copy of the GNU General Public License     *
// *   along with this program; if not, see:                                 *
// *               <http://www.gnu.org/licenses/>.                           *
// ***************************************************************************/

// ============================================================
//  Khalkha Mongolian Spelling-to-Phoneme Rules
//
//  Cyrillic alphabet: а б в г д е ё ж з и й к л м н о ө п р
//                     с т у ү ф х ц ч ш щ ъ ы ь э ю я
//
//  Vowel harmony: back {а,о,у} vs front {э,ө,ү}; и is neutral.
//
//  Key phonological rules:
//    1. Doubled vowels = long vowels
//    2. й after vowel = diphthong (ай, ой, эй, уй/үй)
//    3. н before г/к/х/word-end = velar nasal [ŋ]
//    4. ь (soft sign) palatalizes preceding consonant + creates
//       glide before iotated vowels
//    5. е,ё,ю,я = j+vowel after pause, vowel, or ь
//    6. ы = [i] (archaic, same as и in modern Khalkha)
// ============================================================


// ============================================================
//  VOWELS
// ============================================================

.group а
        аай     a:j
        аа      a:
        ай      aI
        а       a

.group э
        ээй     e:j
        ээ      e:
        эй      eI
        э       e

.group и
        ий      i:
        ии      i:
        и       i

.group о
        оой     O:j
        оо      O:
        ой      OI
        о       O

.group ө
        өөй     8:j
        өө      8:
        ө       8

.group у
        ууй     U:j
        уу      U:
        уй      UI
        у       U

.group ү
        үүй     y:j
        үү      y:
        үй      UI
        ү       y


// -- Iotated vowels: е, ё, ю, я ----------------------------
// Word-initial or after vowel/ь: j + vowel
// After consonant: just the vowel

.group е
        _) еэ       je:
        A) еэ       je:
        ь) еэ       e:
        еэ          e:
        _) е        je
        A) е        je
        ь) е        e
        е           e

.group ё
        _) ё        jO
        A) ё        jO
        ь) ё        O
        ё           O

.group ю
        _) ю        jU
        A) ю        jU
        ь) ю        U
        ю           U

.group я
        _) яа       ja:
        A) яа       ja:
        ь) яа       a:
        яа          a:
        _) я        ja
        A) я        ja
        ь) я        a
        я           a

// -- ы (same as и in modern Khalkha) -----------------------
.group ы
        ы       i


// ============================================================
//  CONSONANTS
// ============================================================

.group б
        б       b

.group в
        в       v

.group г
        г (т    x
        г       g

.group д
        д       d

.group ж
        ж       dZ

.group з
        з       z

.group й
        й       j

.group к
        к       k

.group л
        л       l

.group м
        м       m

// н: velar nasal [N] before velars and at word end
.group н
        н (г    N
        н (к    N
        н (х    N
        н (_    N
        нг (_   N
        н       n

.group п
        п       p

.group р
        р       r

.group с
        с       s

.group т
        т       t

.group ф
        ф       f

.group х
        х       x

.group ц
        ц       ts

.group ч
        ч       tS

.group ш
        ш       S

.group щ
        щ       S

// -- Hard sign / soft sign ---------------------------------
.group ъ
        ъ (я    j
        ъ (ё    j
        ъ (ю    j
        ъ (е    j
        ъ

.group ь
        ь (я    j
        ь (ё    j
        ь (ю    j
        ь (е    j
        ь (и    j
        ь
