mirror of https://github.com/laurent22/joplin.git
Tools: Render translator names as link to prevent website template from breaking
parent
c93f474547
commit
d82eec0fa4
|
@ -10,6 +10,7 @@ require('app-module-path').addPath(`${__dirname}/../ReactNativeClient`);
|
||||||
const rootDir = `${__dirname}/..`;
|
const rootDir = `${__dirname}/..`;
|
||||||
|
|
||||||
const { filename, fileExtension } = require(`${rootDir}/ReactNativeClient/lib/path-utils.js`);
|
const { filename, fileExtension } = require(`${rootDir}/ReactNativeClient/lib/path-utils.js`);
|
||||||
|
const markdownUtils = require(`${rootDir}/ReactNativeClient/lib/markdownUtils`).default;
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const gettextParser = require('gettext-parser');
|
const gettextParser = require('gettext-parser');
|
||||||
|
|
||||||
|
@ -200,6 +201,12 @@ function extractTranslator(regex, poContent) {
|
||||||
return translatorName;
|
return translatorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function translatorNameToMarkdown(translatorName) {
|
||||||
|
const matches = translatorName.match(/^(.*?)\s*\((.*)\)$/);
|
||||||
|
if (!matches) return translatorName;
|
||||||
|
return `[${markdownUtils.escapeTitleText(matches[1])}](mailto:${markdownUtils.escapeLinkUrl(matches[2])})`;
|
||||||
|
}
|
||||||
|
|
||||||
async function translationStatus(isDefault, poFile) {
|
async function translationStatus(isDefault, poFile) {
|
||||||
// "apt install translate-toolkit" to have pocount
|
// "apt install translate-toolkit" to have pocount
|
||||||
let pocountPath = 'pocount';
|
let pocountPath = 'pocount';
|
||||||
|
@ -229,6 +236,13 @@ async function translationStatus(isDefault, poFile) {
|
||||||
translatorName = translatorName.replace(/ </, ' (');
|
translatorName = translatorName.replace(/ </, ' (');
|
||||||
translatorName = translatorName.replace(/>/, ')');
|
translatorName = translatorName.replace(/>/, ')');
|
||||||
|
|
||||||
|
// Some users have very long names and very long email addresses and in that case gettext
|
||||||
|
// records it over several lines, and here we only have the first line. So if we're having a broken
|
||||||
|
// email, add a closing ')' so that at least rendering works fine.
|
||||||
|
if (translatorName.indexOf('(') >= 0 && translatorName.indexOf(')') < 0) translatorName += ')';
|
||||||
|
|
||||||
|
translatorName = translatorNameToMarkdown(translatorName);
|
||||||
|
|
||||||
const isAlways100 = poFile.endsWith('en_US.po');
|
const isAlways100 = poFile.endsWith('en_US.po');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue