mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
1d429b8b09
no issue This PR adds the ability to translate the strings that appear in the newsletter as boilerplate text, using i18next. Variables are in single mustaches ( `{date}` ) in the translation strings (rather than `{{date}}`), because these strings occur both the email template.hbs and also .js files. That necessitated a separate namespace. This PR also includes changes to the newsletter button ("more like this", "less like this", "comment") that were previously delivered on desktop as images that included the text. @sanne-san provided a rework that removed text-as-image from the desktop buttons, and allows more shared code between the two layouts, along with making the buttons translatable. Example usage - handlebars ``` <h3 class="latest-posts-header">{{t 'Keep reading'}}</h3> {{{t 'By {authors}' authors=post.authors }}} ``` (NOTE: triple { required because of possible & ) Example usage - javascript ``` getValue: (member) => { if (member.status === 'comped') { return t('complimentary'); } if (this.isMemberTrialing(member)) { return t('trialing'); } // other possible statuses: t('free'), t('paid') // return t(member.status); } ``` --------- Co-authored-by: Sanne de Vries <sannedv@protonmail.com> Co-authored-by: Steve Larson <9larsons@gmail.com>
38 lines
1.7 KiB
JSON
38 lines
1.7 KiB
JSON
{
|
|
"name": "@tryghost/i18n",
|
|
"version": "0.0.0",
|
|
"repository": "https://github.com/TryGhost/Ghost/tree/main/ghost/i18n",
|
|
"author": "Ghost Foundation",
|
|
"private": true,
|
|
"main": "index.js",
|
|
"types": "./build/i18n.d.ts",
|
|
"scripts": {
|
|
"dev": "echo \"Implement me!\"",
|
|
"test:base": "NODE_ENV=testing c8 --include index.js --include lib --check-coverage --100 --reporter text --reporter cobertura -- mocha --reporter dot './test/**/*.test.js'",
|
|
"test": "yarn test:base && yarn translate",
|
|
"lint:code": "eslint *.js lib/ --ext .js --cache",
|
|
"lint": "yarn lint:code && yarn lint:test",
|
|
"lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache",
|
|
"translate": "yarn translate:ghost && yarn translate:portal && yarn translate:signup-form && yarn translate:comments && yarn translate:search && yarn translate:newsletter && node generate-context.js",
|
|
"translate:ghost": "NAMESPACE=ghost i18next '../core/core/{frontend,server,shared}/**/*.{js,jsx}'",
|
|
"translate:portal": "NAMESPACE=portal i18next '../../apps/portal/src/**/*.{js,jsx}'",
|
|
"translate:signup-form": "NAMESPACE=signup-form i18next '../../apps/signup-form/src/**/*.{ts,tsx}'",
|
|
"translate:comments": "NAMESPACE=comments i18next '../../apps/comments-ui/src/**/*.{ts,tsx}'",
|
|
"translate:search": "NAMESPACE=search i18next '../../apps/sodo-search/src/**/*.{js,jsx,ts,tsx}'",
|
|
"translate:newsletter": "NAMESPACE=newsletter i18next '../email-service/{lib/email-templates/*.hbs,lib/email-templates/partials/*.hbs,lib/*.js}'"
|
|
},
|
|
"files": [
|
|
"index.js",
|
|
"lib",
|
|
"locales"
|
|
],
|
|
"devDependencies": {
|
|
"c8": "8.0.1",
|
|
"i18next-parser": "8.13.0",
|
|
"mocha": "10.2.0"
|
|
},
|
|
"dependencies": {
|
|
"i18next": "23.16.2"
|
|
}
|
|
}
|