How to customize Rails I18n key suffixes like?`_md`?for Markdown | Island94.org

18-Jul-2025 22
If you’ve had reason to use internationalization in Rails on Rails, you’ve probably used a nifty feature of it: Keys with a _html suffix… are marked as HTML safe. When you use them in views the HTML will not be escaped. Authoring HTML within translations can be a pain because HTML is quite verbose and easy to mess up when maintaining multiple versions of the same phrase, or paragraph, or page across multiple languages. It would be nice 💅 to have something like this: Keys with a _md suffix can be authored in Markdown and will be automatically converted to HTML and marked as HTML safe. Markdown is a lot less verbose than HTML and easier to write and eyeball. Let’s do it! First, we have to patch into the I18n translate method. It looks something like this:.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle