# encoding: UTF-8 require 'test_helper' require 'i18n' require 'stringex' class RussianYAMLLocalizationTest < Test::Unit::TestCase def setup Stringex::Localization.reset! Stringex::Localization.backend = :i18n Stringex::Localization.backend.load_translations :ru Stringex::Localization.locale = :ru end { "foo & bar" => "foo и bar", "AT&T" => "AT и T", "99° is normal" => "99 градусов is normal", "4 ÷ 2 is 2" => "4 делить на 2 is 2", "webcrawler.com" => "webcrawler точка com", "Well..." => "Well многоточие", "x=1" => "x равно 1", "a #2 pencil" => "a номер 2 pencil", "100%" => "100 процентов", "cost+tax" => "cost плюс tax", "batman/robin fan fiction" => "batman слеш robin fan fiction", "dial *69" => "dial звезда 69", " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged " }.each do |original, converted| define_method "test_character_conversion: '#{original}'" do assert_equal converted, original.convert_miscellaneous_characters end end { "$100" => "100 долларов", "$19.99" => "19 долларов 99 центов", "£100" => "100 фунтов", "£19.99" => "19 фунтов 99 пенсов", "€100" => "100 евро", "€19.99" => "19 евро 99 центов", "¥1000" => "1000 йен" }.each do |original, converted| define_method "test_currency_conversion: '#{original}'" do assert_equal converted, original.convert_miscellaneous_characters end end { "Tea & Sympathy" => "Tea и Sympathy", "10¢" => "10 центов", "©2000" => "(c)2000", "98° is fine" => "98 градусов is fine", "10÷5" => "10 делить на 5", ""quoted"" => '"quoted"', "to be continued…" => "to be continued...", "2000–2004" => "2000-2004", "I wish—oh, never mind" => "I wish--oh, never mind", "½ ounce of gold" => "половина ounce of gold", "1 and ¼ ounces of silver" => "1 and одна четверть ounces of silver", "9 and ¾ ounces of platinum" => "9 and три четверти ounces of platinum", "3>2" => "3>2", "2<3" => "2<3", "two words" => "two words", "£100" => "фунтов 100", "Walmart®" => "Walmart(r)", "'single quoted'" => "'single quoted'", "2×4" => "2x4", "Programming™" => "Programming(tm)", "¥20000" => "йен 20000", " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged " }.each do |original, converted| define_method "test_html_entity_conversion: '#{original}'" do assert_equal converted, original.convert_miscellaneous_html_entities end end { "½" => "половина", "½" => "половина", "½" => "половина", "⅓" => "одна треть", "⅓" => "одна треть", "⅔" => "две трети", "⅔" => "две трети", "¼" => "одна четверть", "¼" => "одна четверть", "¼" => "одна четверть", "¾" => "три четверти", "¾" => "три четверти", "¾" => "три четверти", "⅕" => "одна пятая", "⅕" => "одна пятая", "⅖" => "две пятых", "⅖" => "две пятых", "⅗" => "три пятых", "⅗" => "три пятых", "⅘" => "четыре пятых", "⅘" => "четыре пятых", "⅙" => "одна шестая", "⅙" => "одна шестая", "⅚" => "пять шестых", "⅚" => "пять шестых", "⅛" => "одна восьмая", "⅛" => "одна восьмая", "⅜" => "три восьмых", "⅜" => "три восьмых", "⅝" => "пять восьмых", "⅝" => "пять восьмых", "⅞" => "семь восьмых", "⅞" => "семь восьмых" }.each do |original, converted| define_method "test_vulgar_fractions_conversion: #{original}" do assert_equal converted, original.convert_vulgar_fractions end end { "foo & bar" => "foo-i-bar", "AT&T" => "at-i-t", "99° is normal" => "99-ghradusov-is-normal", "4 ÷ 2 is 2" => "4-dielit-na-2-is-2", "webcrawler.com" => "webcrawler-tochka-com", }.each do |original, converted| define_method "test_character_conversion: '#{original}'" do assert_equal converted, original.to_url end end end