Skip to content

Instantly share code, notes, and snippets.

@smsohan
Last active December 22, 2015 16:19
Show Gist options
  • Save smsohan/6498918 to your computer and use it in GitHub Desktop.
Save smsohan/6498918 to your computer and use it in GitHub Desktop.
Finds and auto generates the default translations for all missing translations on a Ruby on Rails generated page. Copy this in your chrome console.
// this mehtod is taken from: https://gist.github.com/cyberfox/1301931
var humanize = function(property) {
return property.replace(/_/g, ' ')
.replace(/(\w+)/g, function(match) {
return match.charAt(0).toUpperCase() + match.slice(1);
});
};
console.dir($.map($('.translation_missing'), function(e){ var key = e.title.split(":")[1].trim().substring(3); return key + ": '" + humanize(key) + "' "; }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment