koppen / i18n_missing_keys Goto Github PK
View Code? Open in Web Editor NEWRake task to find localization keys missing from different locales in a Rails application using the I18n::Simple backend.
License: MIT License
Rake task to find localization keys missing from different locales in a Rails application using the I18n::Simple backend.
License: MIT License
I fixed it by replacing this line 'I18n.translate(key, :raise => true)' for 'I18n.translate(key, :raise => true, :fallback => 'false')'.
It seems that we can pass :fallback => 'false' on the I18n.translate calls, but this is not part of the public API.
I think this is an easier solution that the one proposed on #4
Hope it helps
We have a locale file that looks somewhat like the following. Notice that the attributes section is empty since we don't need translations for the attribute names for this model.
en:
activerecord:
attributes:
answer:
models:
answer:
one: "Answer"
other: "Answers"
The rake task will always complain of a missing key 'activerecord.attributes.answer'. I believe it should not complain.
My proposed fix is below.
--- a/lib/tasks/missing_keys.rake
+++ b/lib/tasks/missing_keys.rake
@@ -77,6 +77,7 @@ class MissingKeysFinder
def collect_keys(scope, translations)
full_keys = []
translations.to_a.each do |key, translations|
+ next if translations.nil?
new_scope = scope.dup << key
if translations.is_a?(Hash)
full_keys += collect_keys(new_scope, translations)
I did configure fallback for languages like de for de_AT, no fallback for en. When runing the rake task it does only show results for de, not for en. Deactivating the fallbacks in application.rb means that I get results for all languages. Is there any possibility to deactivate fallbacks temporary inside this rake task?
thx, Leuchteuer
That’s great, exactly what I was looking for! Could you maybe make it a gem? This way it would be easy to load it only in development mode.
Thanks for your efforts!
If the license is e.g. GPL, the project cannot be used as freely as MIT ones, so the licensing should be explicitly presented in all projects.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.