ICU-20407 hy-arevela/hy-arevmda can. into hy / hyw
diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp
index a4902ef..a057491 100644
--- a/icu4c/source/common/uloc.cpp
+++ b/icu4c/source/common/uloc.cpp
@@ -465,6 +465,8 @@
  */
 static const CanonicalizationMap CANONICALIZE_MAP[] = {
     { "art_LOJBAN",     "jbo" }, /* registered name */
+    { "hy__AREVELA",    "hy" }, /* Registered IANA variant */
+    { "hy__AREVMDA",    "hyw" }, /* Registered IANA variant */
     { "zh_GAN",         "gan" }, /* registered name */
     { "zh_GUOYU",       "zh" }, /* registered name */
     { "zh_HAKKA",       "hak" }, /* registered name */
diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c
index 6aec8ef..09de64c 100644
--- a/icu4c/source/test/cintltst/cloctst.c
+++ b/icu4c/source/test/cintltst/cloctst.c
@@ -423,9 +423,7 @@
         {"i-hakka", "", "CN", "", "i-hakka_CN", "i-hakka_CN", NULL},
         {"i-hakka", "", "MX", "", "I-hakka_MX", "i-hakka_MX", NULL},
         {"x-klingon", "", "US", "SANJOSE", "X-KLINGON_us_SANJOSE", "x-klingon_US_SANJOSE", NULL},
-        
-        {"hy", "", "", "AREVMDA", "hy_AREVMDA", "hy__AREVMDA", NULL},
-        
+        {"hy", "", "", "AREVMDA", "hy_AREVMDA", "hy__AREVMDA", "hyw"},
         {"de", "", "", "1901", "de-1901", "de__1901", NULL},
         {"mr", "", "", "", "mr.utf8", "mr.utf8", "mr"},
         {"de", "", "TV", "", "de-tv.koi8r", "de_TV.koi8r", "de_TV"},
diff --git a/icu4c/source/test/intltest/loctest.cpp b/icu4c/source/test/intltest/loctest.cpp
index 3e0c5cb..e3de596 100644
--- a/icu4c/source/test/intltest/loctest.cpp
+++ b/icu4c/source/test/intltest/loctest.cpp
@@ -252,6 +252,7 @@
     TESTCASE_AUTO(TestToLanguageTag);
     TESTCASE_AUTO(TestMoveAssign);
     TESTCASE_AUTO(TestMoveCtor);
+    TESTCASE_AUTO(TestBug20407iVariantPreferredValue);
     TESTCASE_AUTO(TestBug13417VeryLongLanguageTag);
     TESTCASE_AUTO(TestBug11053UnderlineTimeZone);
     TESTCASE_AUTO_END;
@@ -3163,6 +3164,24 @@
     assertEquals("bogus", l7.isBogus(), l8.isBogus());
 }
 
+void LocaleTest::TestBug20407iVariantPreferredValue() {
+    IcuTestErrorCode status(*this, "TestBug20407iVariantPreferredValue()");
+
+    Locale l = Locale::forLanguageTag("hy-arevela", status);
+    status.errIfFailureAndReset("hy-arevela fail");
+    assertTrue("!l.isBogus()", !l.isBogus());
+
+    std::string result = l.toLanguageTag<std::string>(status);
+    assertEquals(l.getName(), "hy", result.c_str());
+
+    l = Locale::forLanguageTag("hy-arevmda", status);
+    status.errIfFailureAndReset("hy-arevmda");
+    assertTrue("!l.isBogus()", !l.isBogus());
+
+    result = l.toLanguageTag<std::string>(status);
+    assertEquals(l.getName(), "hyw", result.c_str());
+}
+
 void LocaleTest::TestBug13417VeryLongLanguageTag() {
     IcuTestErrorCode status(*this, "TestBug13417VeryLongLanguageTag()");
 
diff --git a/icu4c/source/test/intltest/loctest.h b/icu4c/source/test/intltest/loctest.h
index 1ea9f2d..bebb26c 100644
--- a/icu4c/source/test/intltest/loctest.h
+++ b/icu4c/source/test/intltest/loctest.h
@@ -124,6 +124,8 @@
     void TestMoveAssign();
     void TestMoveCtor();
 
+    void TestBug20407iVariantPreferredValue();
+
     void TestBug13417VeryLongLanguageTag();
 
     void TestBug11053UnderlineTimeZone();
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java
index 54827e3..785e790 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java
@@ -342,6 +342,8 @@
         { "de_1906",        "de__1906" }, /* registered name */
         { "en_BOONT",       "en__BOONT" }, /* registered name */
         { "en_SCOUSE",      "en__SCOUSE" }, /* registered name */
+        { "hy__AREVELA",    "hy", null, null }, /* Registered IANA variant */
+        { "hy__AREVMDA",    "hyw", null, null }, /* Registered IANA variant */
         { "sl_ROZAJ",       "sl__ROZAJ" }, /* registered name */
         { "zh_GAN",         "zh__GAN" }, /* registered name */
         { "zh_GUOYU",       "zh" }, /* registered name */
diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java
index 5b657c8..0d53657 100644
--- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java
+++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java
@@ -1489,6 +1489,14 @@
         assertEquals("foobar", target, name);
     }
 
+    @Test
+    public void TestBug20407iVariantPreferredValue() {
+        ULocale uloc = ULocale.createCanonical("hy-arevela");
+        assertEquals("getName()", "hy", uloc.getName());
+        uloc = ULocale.createCanonical("hy-arevmda");
+        assertEquals("getName()", "hyw", uloc.getName());
+    }
+
     private void initHashtable() {
         h[0] = new HashMap<String, String>();
         h[1] = new HashMap<String, String>();