diff options
author | Ruben Davila <rdavila84@gmail.com> | 2017-04-20 22:47:31 -0500 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2017-04-20 22:47:31 -0500 |
commit | 6fbc6befa1768cc68471d17091ef08b2e73fec82 (patch) | |
tree | 3e43cd2d16dd45bcc35d25efc04ce8c6f2c3f4fe /config/initializers/gettext_rails_i18n_patch.rb | |
parent | 4471d7b84fc783a08909473ef0243e6e07d2342a (diff) | |
download | gitlab-ce-6fbc6befa1768cc68471d17091ef08b2e73fec82.tar.gz |
Monkey patch gettext_i18n_rails so it can parse content in Mustache format
Diffstat (limited to 'config/initializers/gettext_rails_i18n_patch.rb')
-rw-r--r-- | config/initializers/gettext_rails_i18n_patch.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/config/initializers/gettext_rails_i18n_patch.rb b/config/initializers/gettext_rails_i18n_patch.rb new file mode 100644 index 00000000000..0413330c608 --- /dev/null +++ b/config/initializers/gettext_rails_i18n_patch.rb @@ -0,0 +1,17 @@ +module GettextI18nRails + class HamlParser + singleton_class.send(:alias_method, :old_convert_to_code, :convert_to_code) + + # We need to convert text in Mustache format + # to a format that can be parsed by Gettext scripts. + # If we found a content like "{{ 'Stage' | translate }}" + # in a HAML file we convert it to "= _('Stage')", that way + # it can be processed by the "rake gettext:find" script. + def self.convert_to_code(text) + text.gsub!(/{{ (.*)( \| translate) }}/, "= _(\\1)") + + old_convert_to_code(text) + end + end +end + |