36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/i18n/processes/console_context.rb', line 36
def guide
Rainbow('i18n-processes IRB Quick Start guide').green.bright + "\n" + "\#{Rainbow('Data as trees').yellow}\n tree(locale)\n used_tree(key_filter: nil, strict: nil)\n unused_tree(locale: base_locale, strict: nil)\n build_tree('es' => {'hello' => 'Hola'})\n\n\#{Rainbow('Traversal').yellow}\n tree = missing_diff_tree('es')\n tree.nodes { |node| }\n tree.nodes.to_a\n tree.leaves { |node| }\n tree.each { |root_node| }\n # also levels, depth_first, and breadth_first\n\n\#{Rainbow('Select nodes').yellow}\n tree.select_nodes { |node| } # new tree with only selected nodes\n\n\#{Rainbow('Match by full key').yellow}\n tree.select_keys { |key, leaf| } # new tree with only selected keys\n tree.grep_keys(/hello/) # grep, using ===\n tree.keys { |key, leaf| } # enumerate over [full_key, leaf_node]\n # Pass {root: true} to include root node in full_key (usually locale)\n\n\#{Rainbow('Nodes').yellow}\n node = node(key, locale)\n node.key # only the part after the last dot\n node.full_key # full key. Includes root key, pass {root: false} to override.\n # also: value, value_or_children_hash, data, walk_to_root, walk_from_root\n Tree::Node.new(key: 'en')\n\n\#{Rainbow('Keys').yellow}\n t(key, locale)\n key_value?(key, locale)\n depluralize_key(key, locale) # convert 'hat.one' to 'hat'\n TEXT\nend\n"
|