Localized js is now served as json (#784)

This commit is contained in:
Ahmad Farhat
2019-09-06 10:56:53 -04:00
committed by Jesus Federico
parent 061b69f962
commit 390ccf71c2
3 changed files with 10 additions and 25 deletions

View File

@ -45,23 +45,8 @@
<%= stylesheet_link_tag themes_primary_path %>
<script type="text/javascript">
// Rail-ish function to translate a string, according to the Rails locales
window.t = function t(key) {
if (!key) {
return "";
}
var keys = key.split('.');
var value = <%= current_translations.to_json.html_safe %>; // Add I18n variables
keys.forEach(key => {
if (value) {
value = value[key];
}
});
return value ? value : "";
}
// Include the correct translated strings for Javascript
window.I18n = <%= current_translations.to_json.html_safe %>
</script>
</head>