shorter message for untranslated strings

This commit is contained in:
Régis Hanol
2013-11-04 11:52:12 +01:00
parent cc27c5f363
commit 934ede7d91
5 changed files with 14 additions and 38 deletions

View File

@ -248,4 +248,3 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
}); });
Discourse.Router = Discourse.Router.reopen({ location: 'discourse_location' }); Discourse.Router = Discourse.Router.reopen({ location: 'discourse_location' });

View File

@ -8,5 +8,3 @@ window.ENV = {
window.Discourse = {}; window.Discourse = {};
Discourse.SiteSettings = {}; Discourse.SiteSettings = {};

View File

@ -60,8 +60,7 @@ I18n.locale = null;
// Set the placeholder format. Accepts `{{placeholder}}` and `%{placeholder}`. // Set the placeholder format. Accepts `{{placeholder}}` and `%{placeholder}`.
I18n.PLACEHOLDER = /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm; I18n.PLACEHOLDER = /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm;
I18n.fallbackRules = { I18n.fallbackRules = {};
};
I18n.pluralizationRules = { I18n.pluralizationRules = {
en: function (n) { en: function (n) {
@ -207,7 +206,7 @@ I18n.translate = function(scope, options) {
} else { } else {
return this.interpolate(translation, options); return this.interpolate(translation, options);
} }
} catch(err) { } catch (error) {
return this.missingTranslation(scope); return this.missingTranslation(scope);
} }
}; };
@ -485,15 +484,9 @@ I18n.findAndTranslateValidNode = function(keys, translation) {
I18n.pluralize = function(count, scope, options) { I18n.pluralize = function(count, scope, options) {
var translation; var translation;
try { try { translation = this.lookup(scope, options); } catch (error) {}
translation = this.lookup(scope, options); if (!translation) { return this.missingTranslation(scope); }
} catch (error) {}
if (!translation) {
return this.missingTranslation(scope);
}
var message;
options = this.prepareOptions(options); options = this.prepareOptions(options);
options.count = count.toString(); options.count = count.toString();
@ -501,24 +494,16 @@ I18n.pluralize = function(count, scope, options) {
var key = pluralizer(Math.abs(count)); var key = pluralizer(Math.abs(count));
var keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key]; var keys = ((typeof key == "object") && (key instanceof Array)) ? key : [key];
message = this.findAndTranslateValidNode(keys, translation); var message = this.findAndTranslateValidNode(keys, translation);
if (message == null) message = this.missingTranslation(scope, keys[0]); if (message == null) message = this.missingTranslation(scope, keys[0]);
return this.interpolate(message, options); return this.interpolate(message, options);
}; };
I18n.missingTranslation = function() { I18n.missingTranslation = function(scope, key) {
var message = '[missing "' + this.currentLocale() var message = '[' + this.currentLocale() + "." + scope;
, count = arguments.length if (key) { message += "." + key; }
; return message + ']';
for (var i = 0; i < count; i++) {
message += "." + arguments[i];
}
message += '" translation]';
return message;
}; };
I18n.currentLocale = function() { I18n.currentLocale = function() {

View File

@ -7,23 +7,16 @@
'defer/google_diff_match_patch': <%= asset_path('defer/google_diff_match_patch.js').inspect.html_safe %> 'defer/google_diff_match_patch': <%= asset_path('defer/google_diff_match_patch.js').inspect.html_safe %>
}; };
var assetPath = function(asset){ return function(asset){ return map[asset]; };
return map[asset];
};
return assetPath;
})(); })();
</script> </script>
<script> <script>
Discourse.CDN = '<%= Rails.configuration.action_controller.asset_host %>'; Discourse.CDN = '<%= Rails.configuration.action_controller.asset_host %>';
Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>'; Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>';
Discourse.BaseUri = '<%= Discourse::base_uri "/" %>'; Discourse.BaseUri = '<%= Discourse::base_uri "/" %>';
Discourse.Environment = '<%= Rails.env %>'; Discourse.Environment = '<%= Rails.env %>';
Discourse.SiteSettings = PreloadStore.get('siteSettings'); Discourse.SiteSettings = PreloadStore.get('siteSettings');
Discourse.Router.map(function() { Discourse.Router.map(function() { Discourse.routeBuilder.call(this); });
Discourse.routeBuilder.call(this);
});
Discourse.start() Discourse.start()
</script> </script>

View File

@ -11,6 +11,7 @@
<link rel="icon" type="image/png" href="<%=SiteSetting.favicon_url%>"> <link rel="icon" type="image/png" href="<%=SiteSetting.favicon_url%>">
<link rel="apple-touch-icon" type="image/png" href="<%=SiteSetting.apple_touch_icon_url%>"> <link rel="apple-touch-icon" type="image/png" href="<%=SiteSetting.apple_touch_icon_url%>">
<%= javascript_include_tag "preload_store" %> <%= javascript_include_tag "preload_store" %>
<%= javascript_include_tag "locales/#{I18n.locale}" %> <%= javascript_include_tag "locales/#{I18n.locale}" %>