|
2 | 2 |
|
3 | 3 | class PseudolocalizationTest < Minitest::Test |
4 | 4 | class DummyBackend |
| 5 | + attr_accessor :translations |
| 6 | + |
| 7 | + def initialize(translations = {}) |
| 8 | + @translations = translations |
| 9 | + end |
| 10 | + |
5 | 11 | def translate(_locale, string, _options) |
6 | 12 | string |
7 | 13 | end |
@@ -67,4 +73,52 @@ def test_it_allows_ignoring_cetain_keys |
67 | 73 | assert_equal('Ignore me, as well Clifford!', @backend.translate(:en, 'Ignore me, as well Clifford!', {})) |
68 | 74 | assert_equal(['Ḥḛḛḽḽṓṓ, ẁṓṓṛḽḍ!'], @backend.translate(:en, ['Hello, world!'], {})) |
69 | 75 | end |
| 76 | + |
| 77 | + def test_it_exposes_pseudo_localized_translations |
| 78 | + translations = { |
| 79 | + en: { |
| 80 | + date: { |
| 81 | + day_names: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], |
| 82 | + }, |
| 83 | + hello: 'Hello, world!', |
| 84 | + ignored: { |
| 85 | + foobar: "Foobar" |
| 86 | + } |
| 87 | + }, |
| 88 | + es: { |
| 89 | + date: { |
| 90 | + day_names: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes'], |
| 91 | + }, |
| 92 | + hello: 'Hola, mundo!', |
| 93 | + ignored: { |
| 94 | + foobar: "Foobar" |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + expected = { |
| 99 | + en: { |
| 100 | + date: { |
| 101 | + day_names: ["Ṣṵṵṇḍααẏẏ", "Ṁṓṓṇḍααẏẏ", "Ṫṵṵḛḛṡḍααẏẏ", "Ŵḛḛḍṇḛḛṡḍααẏẏ", "Ṫḥṵṵṛṡḍααẏẏ", "Ḟṛḭḭḍααẏẏ"], |
| 102 | + }, |
| 103 | + hello: "Ḥḛḛḽḽṓṓ, ẁṓṓṛḽḍ!", |
| 104 | + ignored: { |
| 105 | + foobar: "Foobar" |
| 106 | + } |
| 107 | + }, |
| 108 | + es: { |
| 109 | + date: { |
| 110 | + day_names: ["Ḍṓṓṃḭḭṇḡṓṓ", "Ḻṵṵṇḛḛṡ", "Ṁααṛṭḛḛṡ", "Ṁḭḭéṛͼṓṓḽḛḛṡ", "Ĵṵṵḛḛṽḛḛṡ", "Ṿḭḭḛḛṛṇḛḛṡ"], |
| 111 | + }, |
| 112 | + hello: "Ḥṓṓḽαα, ṃṵṵṇḍṓṓ!", |
| 113 | + ignored: { |
| 114 | + foobar: "Foobar" |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + @backend = Pseudolocalization::I18n::Backend.new(DummyBackend.new(translations)) |
| 120 | + @backend.ignores = ["ignored*"] |
| 121 | + |
| 122 | + assert_equal(expected, @backend.translations) |
| 123 | + end |
70 | 124 | end |
0 commit comments