Skip to content

Commit

Permalink
Make I18n systems more robust against missing keys in pluralization data
Browse files Browse the repository at this point in the history
Should make situations like diaspora#4468 less frequent
  • Loading branch information
jhass committed Aug 30, 2013
1 parent 9d092c1 commit 0cdfc7c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* 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)
* 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
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)
Expand Down
10 changes: 5 additions & 5 deletions app/assets/javascripts/helpers/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
translatedMessage,
nextNamespace;

if(views && typeof views.count !== "undefined") {
items.push(this.pluralizationKey(views.count));
}

while(nextNamespace = items.shift()) {
translatedMessage = (translatedMessage)
? translatedMessage[nextNamespace]
Expand All @@ -29,11 +33,7 @@
return "";
}
}

if(views && typeof views.count !== "undefined") {
translatedMessage = translatedMessage[this.pluralizationKey(views.count)];
}


return _.template(translatedMessage, views || {});
}
};
1 change: 1 addition & 0 deletions lib/i18n_interpolation_fallbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def translate(locale, key, options = {})
result = super(fallback, key, options)
return result unless result.nil?
rescue I18n::MissingInterpolationArgument
rescue I18n::InvalidPluralizationData
end
end

Expand Down

0 comments on commit 0cdfc7c

Please sign in to comment.