Make I18n systems more robust against missing keys in pluralization data

Should make situations like #4468 less frequent
This commit is contained in:
Jonne Haß 2013-08-30 19:30:01 +02:00
parent 9d092c1b2f
commit 0cdfc7cfbd
3 changed files with 7 additions and 5 deletions

View file

@ -12,6 +12,7 @@
* Fix preview with more than one mention [#4450](https://github.com/diaspora/diaspora/issues/4450) * Fix preview with more than one mention [#4450](https://github.com/diaspora/diaspora/issues/4450)
* Fix size of images in the SPV [#4471](https://github.com/diaspora/diaspora/pull/4471) * Fix size of images in the SPV [#4471](https://github.com/diaspora/diaspora/pull/4471)
* Adjust 404 message description to not leak logged out users if a post exists or not [#4477](https://github.com/diaspora/diaspora/pull/4477) * Adjust 404 message description to not leak logged out users if a post exists or not [#4477](https://github.com/diaspora/diaspora/pull/4477)
* Make I18n system more robust against missing keys in pluralization data
## Features ## Features
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353) * Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)

View file

@ -20,6 +20,10 @@
translatedMessage, translatedMessage,
nextNamespace; nextNamespace;
if(views && typeof views.count !== "undefined") {
items.push(this.pluralizationKey(views.count));
}
while(nextNamespace = items.shift()) { while(nextNamespace = items.shift()) {
translatedMessage = (translatedMessage) translatedMessage = (translatedMessage)
? translatedMessage[nextNamespace] ? translatedMessage[nextNamespace]
@ -29,11 +33,7 @@
return ""; return "";
} }
} }
if(views && typeof views.count !== "undefined") {
translatedMessage = translatedMessage[this.pluralizationKey(views.count)];
}
return _.template(translatedMessage, views || {}); return _.template(translatedMessage, views || {});
} }
}; };

View file

@ -10,6 +10,7 @@ module I18n
result = super(fallback, key, options) result = super(fallback, key, options)
return result unless result.nil? return result unless result.nil?
rescue I18n::MissingInterpolationArgument rescue I18n::MissingInterpolationArgument
rescue I18n::InvalidPluralizationData
end end
end end