From 77d9e3f9b49821af3ec9b4fbac574c75b02d0351 Mon Sep 17 00:00:00 2001
From: Ruben Davila <rdavila84@gmail.com>
Date: Mon, 24 Apr 2017 22:36:14 -0500
Subject: [PATCH] Monkey patch gettext_i18n_rails so it can parse content in
 Mustache format

---
 .../initializers/gettext_rails_i18n_patch.rb  | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 config/initializers/gettext_rails_i18n_patch.rb

diff --git a/config/initializers/gettext_rails_i18n_patch.rb b/config/initializers/gettext_rails_i18n_patch.rb
new file mode 100644
index 00000000000..c6b841aacd6
--- /dev/null
+++ b/config/initializers/gettext_rails_i18n_patch.rb
@@ -0,0 +1,19 @@
+require 'gettext_i18n_rails/haml_parser'
+
+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
+
-- 
GitLab