Skip to content

Instantly share code, notes, and snippets.

@rcknr
Last active October 19, 2015 19:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcknr/24054abe76ba54d6883e to your computer and use it in GitHub Desktop.
Save rcknr/24054abe76ba54d6883e to your computer and use it in GitHub Desktop.
UI translation (i18n) for Squarespace
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.min.js"></script>
<script>
Y.use('node', 'node-load', function(Y) {
Y.on('domready', function() {
/* Locale to use with moments.js */
var locale = 'de_AT';
/* Format blog entries published dates */
Y.all('time.published').each(
function() {
this.setHTML(moment(this.getAttribute('datetime'), 'YYYY-MM-DD', locale).format('LL'));
}
);
/* Format event dates */
Y.all('time.event-date').each(
function() {
this.setHTML(moment(this.getAttribute('datetime'), 'YYYY-MM-DD', locale).format('dddd, LL'));
}
);
/* Set custom callback for 'timesince' elements, e.g. in Twitter block */
Y.Squarespace.DateUtils.humanizeDate = function(date) {
return moment(date, 'x', locale).fromNow();
}
Y.all('span.timesince').each(
function() {
this.setHTML(Y.Squarespace.DateUtils.humanizeDate(this.getAttribute('data-date')));
}
);
/* Translate strings */
[
['.ss-social-button', 'Share', 'Teilen'],
['.twitter-follow-button', 'Follow', 'Folgen'],
['css selector', 'search for', 'replace with'],
['css selector', 'value']
].forEach(function(t) {
Y.all(t[0]).each(
function() {
this.setHTML(t.length == 3 ? this.getHTML().replace(t[1], t[2]) : t[1]);
});
});
/* Translate form error messages */
Y.Squarespace.FormSubmit.prototype._createErrorNode = function(error) {
error = error.replace('is required', 'ist erforderlich');
return Y.Node.create('<div class="field-error">' + error + "</div>");
}
});
});
</script>
.event-time-12hr {
display: none;
}
.event-time-24hr {
display: block;
}
.eventitem-backlink:before {
content: "\2190\0020 Zurück";
}
.eventitem-content-footer .eventitem-sourceurl:before {
content: "Quelle: ";
}
.eventlist-meta-address-maplink:before {
content: "(Karte)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment