metadata {

authority_id: mv
id: 1987
language: iso-639-2:div
source_script: Thaa
destination_script: Latn
name: Maldivian (Divehi) Romanization system (1987)
url: https://www.eki.ee/wgrs/rom2_dv.htm
creation_date: 1887
description: |
  In 1987 the Maldivian government adopted a system for the romanization of Maldivian. It was also approved by the BGN and the PCGN in 1988.
  Maldivian is written from right to left. Vowels are marked as diacritical marks accompanying a consonant character.

notes:
  - The character އ is not romanized. If it bears a vowel character, that vowel character alone is romanized, e.g. އިރުގައި irugai.
  - Characters އް and ށް word-finally and before a digraph are romanized h, e.g. ވޭވަށް Veyvah, ކެރެއްދޫ Kerehdhoo. In other cases,
    when އް and ށް are used, the romanized value of the following consonant character is doubled, e.g. ބައްޓެށް batteh, ކަޅެހުއްޓާ Kalhehuttaa.
  - The character ނ is romanized n’ if used without any vowel or auxiliary sign. For example kan’du (ކަނޑު).
  - The character އ is Not romanized but see note 1
  - Character ތް is romanized iy, e.g. ޒިޔާރަތްފުށި Ziyaaraiyfushi.

}

tests {

test "އެނބޫދޫ", "en’boodhoo"
test "ކަޅެހުއްޓާ", "kalhehuttaa"
test "ކެރެށްދޫ", "kerehdhoo"
test "ވޭވައް", "veyvah"
test "ކަނޑުފުށި", "kan’dufushi"
test "ޒިޔާރަތްފުށި", "ziyaaraiyfushi"
test "ރައްކާތެރިކުރުމާއި", "rakkaatherikurumaai"
test "ދަރިވަރެއްގެވެސް", "dharivareggeves"
test "ދަރިވަރުންނާއި", "dharivarun’n’aai"
test "ރަށްރަށުގައި", "rarrashugai"
test "ޑިޕާޓްމަންޓުން", "dipaatman’tun’"
test "ހޯދިފައިނުވާ", "hoadhifain’uvaa"

}

stage {

# RULES
# Note 4
sub "\u0787\u07b0", "h", after: any("ހ")
sub "\u0787\u07b0", "h", after: any("ށ")
sub "\u0787\u07b0", "n", after: any("ނ")
sub "\u0787\u07b0", "r", after: any("ރ")
sub "\u0787\u07b0", "b", after: any("ބ")
sub "\u0787\u07b0", "h", after: any("ޅ")
sub "\u0787\u07b0", "k", after: any("ކ")
sub "\u0787\u07b0", "v", after: any("ވ")
sub "\u0787\u07b0", "m", after: any("މ")
sub "\u0787\u07b0", "f", after: any("ފ")
sub "\u0787\u07b0", "h", after: any("ދ")
sub "\u0787\u07b0", "h", after: any("ތ")
sub "\u0787\u07b0", "l", after: any("ލ")
sub "\u0787\u07b0", "g", after: any("ގ")
sub "\u0787\u07b0", "h", after: any("ޏ")
sub "\u0787\u07b0", "s", after: any("ސ")
sub "\u0787\u07b0", "d", after: any("ޑ")
sub "\u0787\u07b0", "j", after: any("ޖ")
sub "\u0787\u07b0", "h", after: any("ޗ")
sub "\u0787\u07b0", "z", after: any("ޒ")
sub "\u0787\u07b0", "t", after: any("ޓ")
sub "\u0787\u07b0", "p", after: any("ޕ")
sub "\u0787\u07b0", "y", after: any("ޔ")

sub "\u0781\u07b0", "h", after: any("ހ")
sub "\u0781\u07b0", "h", after: any("ށ")
sub "\u0781\u07b0", "n", after: any("ނ")
sub "\u0781\u07b0", "r", after: any("ރ")
sub "\u0781\u07b0", "b", after: any("ބ")
sub "\u0781\u07b0", "h", after: any("ޅ")
sub "\u0781\u07b0", "k", after: any("ކ")
sub "\u0781\u07b0", "v", after: any("ވ")
sub "\u0781\u07b0", "m", after: any("މ")
sub "\u0781\u07b0", "f", after: any("ފ")
sub "\u0781\u07b0", "h", after: any("ދ")
sub "\u0781\u07b0", "h", after: any("ތ")
sub "\u0781\u07b0", "l", after: any("ލ")
sub "\u0781\u07b0", "g", after: any("ގ")
sub "\u0781\u07b0", "h", after: any("ޏ")
sub "\u0781\u07b0", "s", after: any("ސ")
sub "\u0781\u07b0", "d", after: any("ޑ")
sub "\u0781\u07b0", "j", after: any("ޖ")
sub "\u0781\u07b0", "h", after: any("ޗ")
sub "\u0781\u07b0", "z", after: any("ޒ")
sub "\u0781\u07b0", "t", after: any("ޓ")
sub "\u0781\u07b0", "p", after: any("ޕ")
sub "\u0781\u07b0", "y", after: any("ޔ")

sub "\u0787\u07b0", "h", after: boundary
sub "\u0781\u07b0", "h", after: boundary

# Note 5
sub "\u0782", "n’", not_after: "=" + any("\u07a6\u07a7\u07a8\u07a9\u07aa\u07ab\u07ac\u07ad\u07ae\u07af\u07B0")

# Note 6
sub "\u078C", "iy", after: "\u07B0"

# CHARACTERS
parallel {
  # Vowels
  sub "ަ", "a"
  sub "ާ", "aa"
  sub "ި", "i"
  sub "ީ", "ee"
  sub "ު", "u"
  sub "ޫ", "oo"
  sub "ެ", "e"
  sub "ޭ", "ey"
  sub "ޮ", "o"
  sub "ޯ", "oa"
  sub "ް", "" # not romanized but see notes 4 & 6

  # Consonants
  sub "ހ", "h"
  sub "ށ", "sh" # Note 4
  sub "ނ", "n" # Note 5
  sub "ރ", "r"
  sub "ބ", "b"
  sub "ޅ", "lh"
  sub "ކ", "k"
  sub "އ", "" # Notes 3 & 4
  sub "ވ", "v"
  sub "މ", "m"
  sub "ފ", "f"
  sub "ދ", "dh"
  sub "ތ", "th" # Note 6
  sub "ލ", "l"
  sub "ގ", "g"
  sub "ޏ", "gn"
  sub "ސ", "s"
  sub "ޑ", "d"
  sub "ޖ", "j"
  sub "ޗ", "ch"
  sub "ޒ", "z"
  sub "ޓ", "t"
  sub "ޕ", "p"
  sub "ޔ", "y"
}

}