mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛Fixed i18n for the {{meta_title}}
helper (#9468)
closes #9466 - make 'page' in the meta title translatable through subexpression in the meta title helper - e.g. `{{meta_title page=(t....)}}`
This commit is contained in:
parent
63aeebb144
commit
7ed822cc0c
3 changed files with 24 additions and 2 deletions
|
@ -12,7 +12,7 @@ function getTitle(data, root, options) {
|
||||||
options = options ? options : {};
|
options = options ? options : {};
|
||||||
|
|
||||||
if (pagination && pagination.total > 1) {
|
if (pagination && pagination.total > 1) {
|
||||||
pageString = ' (Page ' + pagination.page + ')';
|
pageString = _.has(options.hash, 'page') ? options.hash.page.replace('%', pagination.page) : ' (Page ' + pagination.page + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's a specific meta title
|
// If there's a specific meta title
|
||||||
|
|
|
@ -7,5 +7,5 @@ var proxy = require('./proxy'),
|
||||||
|
|
||||||
// We use the name meta_title to match the helper for consistency:
|
// We use the name meta_title to match the helper for consistency:
|
||||||
module.exports = function meta_title(options) { // eslint-disable-line camelcase
|
module.exports = function meta_title(options) { // eslint-disable-line camelcase
|
||||||
return getMetaDataTitle(this, options.data.root);
|
return getMetaDataTitle(this, options.data.root, options);
|
||||||
};
|
};
|
||||||
|
|
|
@ -93,6 +93,28 @@ describe('getTitle', function () {
|
||||||
title.should.equal('Tag Name - My blog title 3 (Page 39)');
|
title.should.equal('Tag Name - My blog title 3 (Page 39)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return translated pagination-string if passed in options object', function () {
|
||||||
|
localSettingsCache.title = 'This is my blog title';
|
||||||
|
|
||||||
|
var title = getTitle({
|
||||||
|
tag: {
|
||||||
|
name: 'Tag Name'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
context: ['tag', 'paged'],
|
||||||
|
pagination: {
|
||||||
|
total: 40,
|
||||||
|
page: 23
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
hash: {
|
||||||
|
page: ' p.%'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
title.should.equal('Tag Name - This is my blog title p.23');
|
||||||
|
});
|
||||||
|
|
||||||
it('should return tag meta_title if in tag data', function () {
|
it('should return tag meta_title if in tag data', function () {
|
||||||
var title = getTitle({
|
var title = getTitle({
|
||||||
tag: {
|
tag: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue