All Projects → fphilipe → I18n Debug

fphilipe / I18n Debug

Licence: mit
Ever wondered which translations are being looked up by Rails, a gem, or simply your app? Wonder no more!

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to I18n Debug

Mobility
Pluggable Ruby translation framework
Stars: ✭ 644 (+350.35%)
Mutual labels:  translation, i18n, rails
Spree i18n
I18n translation files for Spree Commerce.
Stars: ✭ 338 (+136.36%)
Mutual labels:  translation, i18n, rails
Gitlab I18n Patch
Unofficial Japanese translation for GitLab Community Edition.
Stars: ✭ 98 (-31.47%)
Mutual labels:  translation, i18n
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (-29.37%)
Mutual labels:  translation, i18n
Traduora
Ever® Traduora - Open-Source Translation Management Platform
Stars: ✭ 1,580 (+1004.9%)
Mutual labels:  translation, i18n
Transloco
🚀 😍 The internationalization (i18n) library for Angular
Stars: ✭ 1,185 (+728.67%)
Mutual labels:  translation, i18n
Translate enum
Easily Translate Enums in Rails
Stars: ✭ 90 (-37.06%)
Mutual labels:  i18n, rails
I18n Ally
🌍 All in one i18n extension for VS Code
Stars: ✭ 1,931 (+1250.35%)
Mutual labels:  translation, i18n
React Intl Hooks
React hooks for internationalization without the hassle ⚛️🌍
Stars: ✭ 64 (-55.24%)
Mutual labels:  translation, i18n
Dom I18n
Provides a very basic HTML multilingual support using JavaScript
Stars: ✭ 125 (-12.59%)
Mutual labels:  translation, i18n
React I18nify
Simple i18n translation and localization components and helpers for React.
Stars: ✭ 123 (-13.99%)
Mutual labels:  translation, i18n
Go I18n
Translate your Go program into multiple languages.
Stars: ✭ 1,834 (+1182.52%)
Mutual labels:  translation, i18n
Elm I18n
Localization for Elm apps as a pre-build phase with import and export between elm code and CSV/PO
Stars: ✭ 68 (-52.45%)
Mutual labels:  translation, i18n
Ifme
Free, open source mental health communication web app to share experiences with loved ones
Stars: ✭ 1,147 (+702.1%)
Mutual labels:  i18n, rails
Pootle
Online translation tool
Stars: ✭ 1,346 (+841.26%)
Mutual labels:  translation, i18n
Gettext Go
🆎 GNU gettext for Go (Imported By Kubernetes)
Stars: ✭ 66 (-53.85%)
Mutual labels:  translation, i18n
Pseudo Localization
Dynamic pseudo-localization in the browser and nodejs
Stars: ✭ 109 (-23.78%)
Mutual labels:  translation, i18n
Punic
PHP translation and localization made easy!
Stars: ✭ 133 (-6.99%)
Mutual labels:  translation, i18n
Texterify
The localization management system.
Stars: ✭ 37 (-74.13%)
Mutual labels:  i18n, rails
Atom I18n
:atom: One Atom i18n Package for Any Locale 🌏 🌎 🌍
Stars: ✭ 56 (-60.84%)
Mutual labels:  translation, i18n

Ruby I18n Debug

Build Status Gem Version

Ever wondered which translations are being looked up by Rails, a gem, or simply your app? Wonder no more!

Rails' implicit translations, for instance, are a nice feature. But sometimes getting the key to, let's say, the BillingAddress' street attribute in a nested form inside an Order can be quite tricky to get right on the first try. The key for this example would be activerecord.attributes.order/billing_address.street. Good luck figuring that out!

With this gem you can easily see which translations are being looked up. The key above would have created the following debug log entry:

[i18n-debug] activerecord.attributes.order/billing_address.name => nil

After setting the translation for that key you just discovered, the log entry changes to this:

[i18n-debug] activerecord.attributes.order/billing_address.name => "Order billing name"

Installation

Simply add the gem to your Gemfile. You probably only want this in development. Thus, place it inside the development group.

gem 'i18n-debug', group: :development

If you need support for ruby <= 2.0, make sure to use version 1.0.0.

Usage

This gem works straight out of the box. If Rails is available, it will log using Rails.logger.debug. Otherwise it will log using Logger.new($stdout).debug.

If you wish to use a custom logger, simply set it as follows (make sure it responds to debug):

I18n::Debug.logger = my_custom_logger

Every lookup invokes the lambda I18n::Debug.on_lookup with the key and the translation value as arguments. The default lambda simply logs it to the logger mentioned above. If you want to change the logging format or do something totally different, simply set your own handler to do so:

# Collect stats on I18n key usage.
i18n_stats = Hash.new { |stats, key| stats[key] = 0 }

I18n::Debug.on_lookup do |key, value|
  i18n_stats[key] += 1 if value
end

Additional Information

Dependencies

Author

Philipe Fatio (fphilipe)

License

MIT License. Copyright 2014 Philipe Fatio

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].