X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/dae3dcf87edcfc0648cd0b93b069b0eee67d3ab7..f8ed06b10dadae1a6e3942bbd29e5193437c8ea9:/test/lib/locale_test.rb diff --git a/test/lib/locale_test.rb b/test/lib/locale_test.rb index a100515c8..9aec035d1 100644 --- a/test/lib/locale_test.rb +++ b/test/lib/locale_test.rb @@ -32,43 +32,43 @@ class LocaleTest < ActiveSupport::TestCase end def test_script - assert_equal EN.script, Locale.tag("en").script - assert_equal EN_GB.script, Locale.tag("en-GB").script - assert_equal FR.script, Locale.tag("fr").script - assert_equal ZH_HANS.script, Locale.tag("zh-Hans").script - assert_equal ZH_HANT_TW.script, Locale.tag("zh-Hant-TW").script - assert_equal ZH_YUE.script, Locale.tag("zh-yue").script - assert_equal ZH_YUE.script, Locale.tag("zh-YUE").script - assert_equal BE_TARASK.script, Locale.tag("be-tarask").script - assert_equal BE_TARASK.script, Locale.tag("be-Tarask").script + assert_equal_allowing_nil EN.script, Locale.tag("en").script + assert_equal_allowing_nil EN_GB.script, Locale.tag("en-GB").script + assert_equal_allowing_nil FR.script, Locale.tag("fr").script + assert_equal_allowing_nil ZH_HANS.script, Locale.tag("zh-Hans").script + assert_equal_allowing_nil ZH_HANT_TW.script, Locale.tag("zh-Hant-TW").script + assert_equal_allowing_nil ZH_YUE.script, Locale.tag("zh-yue").script + assert_equal_allowing_nil ZH_YUE.script, Locale.tag("zh-YUE").script + assert_equal_allowing_nil BE_TARASK.script, Locale.tag("be-tarask").script + assert_equal_allowing_nil BE_TARASK.script, Locale.tag("be-Tarask").script end def test_region - assert_equal EN.region, Locale.tag("en").region - assert_equal EN_GB.region, Locale.tag("en-GB").region - assert_equal FR.region, Locale.tag("fr").region - assert_equal ZH_HANS.region, Locale.tag("zh-Hans").region - assert_equal ZH_HANT_TW.region, Locale.tag("zh-Hant-TW").region - assert_equal ZH_YUE.region, Locale.tag("zh-yue").region - assert_equal ZH_YUE.region, Locale.tag("zh-YUE").region - assert_equal BE_TARASK.region, Locale.tag("be-tarask").region - assert_equal BE_TARASK.region, Locale.tag("be-Tarask").region + assert_equal_allowing_nil EN.region, Locale.tag("en").region + assert_equal_allowing_nil EN_GB.region, Locale.tag("en-GB").region + assert_equal_allowing_nil FR.region, Locale.tag("fr").region + assert_equal_allowing_nil ZH_HANS.region, Locale.tag("zh-Hans").region + assert_equal_allowing_nil ZH_HANT_TW.region, Locale.tag("zh-Hant-TW").region + assert_equal_allowing_nil ZH_YUE.region, Locale.tag("zh-yue").region + assert_equal_allowing_nil ZH_YUE.region, Locale.tag("zh-YUE").region + assert_equal_allowing_nil BE_TARASK.region, Locale.tag("be-tarask").region + assert_equal_allowing_nil BE_TARASK.region, Locale.tag("be-Tarask").region end def test_variant - assert_equal EN.variant, Locale.tag("en").variant - assert_equal EN_GB.variant, Locale.tag("en-GB").variant - assert_equal FR.variant, Locale.tag("fr").variant - assert_equal ZH_HANS.variant, Locale.tag("zh-Hans").variant - assert_equal ZH_HANT_TW.variant, Locale.tag("zh-Hant-TW").variant - assert_equal ZH_YUE.variant, Locale.tag("zh-yue").variant - assert_equal ZH_YUE.variant, Locale.tag("zh-YUE").variant - assert_equal BE_TARASK.variant, Locale.tag("be-tarask").variant - assert_equal BE_TARASK.variant, Locale.tag("be-Tarask").variant + assert_equal_allowing_nil EN.variant, Locale.tag("en").variant + assert_equal_allowing_nil EN_GB.variant, Locale.tag("en-GB").variant + assert_equal_allowing_nil FR.variant, Locale.tag("fr").variant + assert_equal_allowing_nil ZH_HANS.variant, Locale.tag("zh-Hans").variant + assert_equal_allowing_nil ZH_HANT_TW.variant, Locale.tag("zh-Hant-TW").variant + assert_equal_allowing_nil ZH_YUE.variant, Locale.tag("zh-yue").variant + assert_equal_allowing_nil ZH_YUE.variant, Locale.tag("zh-YUE").variant + assert_equal_allowing_nil BE_TARASK.variant, Locale.tag("be-tarask").variant + assert_equal_allowing_nil BE_TARASK.variant, Locale.tag("be-Tarask").variant end def test_list - assert_equal [], Locale.list + assert_empty Locale.list assert_equal [EN], Locale.list("en") assert_equal [EN, ZH_YUE, ZH_HANT_TW], Locale.list("en", "zh-yue", "zh-Hant-TW") assert_equal [ZH_YUE, ZH_HANT_TW], Locale.list("en;de", "zh-yue", "zh-Hant-TW") @@ -80,7 +80,7 @@ class LocaleTest < ActiveSupport::TestCase end def test_available - assert_equal I18n.available_locales.count, Locale.available.count + assert_operator Locale.available.count, :<=, I18n.available_locales.count end def test_preferred @@ -91,9 +91,12 @@ class LocaleTest < ActiveSupport::TestCase assert_equal "de", Locale.available.preferred(Locale.list("zh-Hant", "de")).to_s assert_equal "zh-TW", Locale.available.preferred(Locale.list("zh-Hant-TW", "de")).to_s assert_equal "zh-TW", Locale.available.preferred(Locale.list("zh-TW", "de")).to_s - assert_equal "zh-HK", Locale.available.preferred(Locale.list("yue", "zh-HK", "de")).to_s - assert_equal "zh-yue", Locale.available. preferred(Locale.list("yue", "zh-yue", "zh-HK", "de")).to_s - assert_equal "zh-yue", Locale.available. preferred(Locale.list("yue", "zh-YUE", "zh-HK", "de")).to_s + assert_equal "zh-HK", Locale.available.preferred( + Locale.list("zh-HK", "zh-hk", "zh-Hant", "zh-hant", "zh-TW", "zh-tw", "zh", "zh-yue", + "yue", "yue-Hant", "yue-HK", "yue-Hans", "zh-classical", "lzh", "ja-Hani", + "ko-Hani", "ko_hanja", "vi-Hani", "ja-hani", "ko-hani", "vi-hani", "en-HK", + "en-hk", "en-SG", "en-sg", "en-GB", "en-gb", "en-US", "en-us", "en", "ja") + ).to_s assert_equal "en", Locale.available.preferred(Locale.list("yue")).to_s end end