2020-10-27 06:44:01 -04:00
|
|
|
/*
|
|
|
|
This script will aid the process of inserting HTML fragments into all the
|
|
|
|
locales.
|
|
|
|
We are migrating from
|
|
|
|
locale: 'PRE __keyLinkOpen__INNER__keyLinkClose__ POST'
|
|
|
|
pug: translate(localeKey, { keyLinkOpen: '<a ...>', keyLinkClose: '</a>' })
|
|
|
|
to
|
|
|
|
locale: 'PRE <0>INNER</0> POST'
|
|
|
|
pug: translate(localeKey, {}, [{ name: 'a', attrs: { href: '...', ... }}])
|
|
|
|
|
|
|
|
|
|
|
|
MAPPING entries:
|
|
|
|
localeKey: ['keyLinkOpen', 'keyLinkClose']
|
|
|
|
faq_pay_by_invoice_answer: ['payByInvoiceLinkOpen', 'payByInvoiceLinkClose']
|
|
|
|
*/
|
2024-10-24 08:18:37 -04:00
|
|
|
import TransformLocales from './transformLocales.js'
|
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
2020-10-30 08:33:35 -04:00
|
|
|
const MAPPING = {
|
|
|
|
also_provides_free_plan: ['registerLinkOpen', 'registerLinkClose'],
|
2021-04-27 03:52:58 -04:00
|
|
|
faq_pay_by_invoice_answer: ['payByInvoiceLinkOpen', 'payByInvoiceLinkClose'],
|
2020-10-30 08:33:35 -04:00
|
|
|
}
|
2020-10-27 06:44:01 -04:00
|
|
|
|
|
|
|
function transformLocale(locale, [open, close]) {
|
|
|
|
const i18nOpen = `__${open}__`
|
|
|
|
const i18nClose = `__${close}__`
|
|
|
|
if (locale.includes(i18nOpen)) {
|
|
|
|
locale = locale.replace(i18nOpen, '<0>').replace(i18nClose, '</0>')
|
|
|
|
}
|
|
|
|
return locale
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
2024-10-24 08:18:37 -04:00
|
|
|
TransformLocales.transformLocales(MAPPING, transformLocale)
|
2020-10-27 06:44:01 -04:00
|
|
|
}
|
|
|
|
|
2024-10-24 08:18:37 -04:00
|
|
|
if (
|
|
|
|
fileURLToPath(import.meta.url).replace(/\.js$/, '') ===
|
|
|
|
process.argv[1].replace(/\.js$/, '')
|
|
|
|
) {
|
2020-10-27 06:44:01 -04:00
|
|
|
main()
|
|
|
|
}
|