diff --git a/src/js/render.js b/src/js/render.js
index e3a0e20..cab0567 100644
--- a/src/js/render.js
+++ b/src/js/render.js
@@ -112,7 +112,7 @@ export function renderDetails() {
const translationsHTML = `
- ${wordNameDisplay}${homonymnNumber > 0 ? ' ' + homonymnNumber.toString() + '' : ''}
+ ${wordNameDisplay}${homonymnNumber > 0 ? ' ' + homonymnNumber.toString() + '' : ''}
${word.pronunciation}
${word.partOfSpeech}
${isPublic ? `➦` : ''}
diff --git a/src/js/view/render.js b/src/js/view/render.js
index 5aeb88a..da0fc5f 100644
--- a/src/js/view/render.js
+++ b/src/js/view/render.js
@@ -4,7 +4,7 @@ import { getWordsStats, getHomonymnNumber } from './utilities';
import { getMatchingSearchWords, highlightSearchTerm, getSearchFilters, getSearchTerm } from './search';
import { showSection } from './displayToggles';
import { setupSearchFilters, setupInfoModal } from './setupListeners';
-import { parseReferences } from './wordManagement';
+import { parseReferences, translateOrthography } from './wordManagement';
import { renderAd } from '../ads';
import { sortWords } from './wordManagement';
@@ -79,7 +79,7 @@ export function renderDetails() {
const translationsHTML = `Translations
${translations.map(translation => {
translation = translation.split('=').map(value => value.trim());
if (translation.length > 1 && translation[0] !== '' && translation[1] !== '') {
- return `${translation[0]}${translation[1]}`;
+ return `${translation[0]}${translation[1]}`;
}
return false;
}).filter(html => html !== false).join(' ')}
`;
@@ -170,9 +170,11 @@ export function renderWords() {
wordsHTML += renderAd(displayIndex);
+ let wordNameDisplay = translateOrthography(word.name);
+
wordsHTML += `
- ${word.name}${homonymnNumber > 0 ? ' ' + homonymnNumber.toString() + '' : ''}
+ ${wordNameDisplay}${homonymnNumber > 0 ? ' ' + homonymnNumber.toString() + '' : ''}
${word.pronunciation}
${word.partOfSpeech}
➦
diff --git a/src/js/view/wordManagement.js b/src/js/view/wordManagement.js
index 8dfb04f..6a61ff0 100644
--- a/src/js/view/wordManagement.js
+++ b/src/js/view/wordManagement.js
@@ -11,13 +11,23 @@ export function sortWords() {
});
}
+export function translateOrthography(word) {
+ window.currentDictionary.details.orthography.translations.forEach(translation => {
+ translation = translation.split('=').map(value => value.trim());
+ if (translation.length > 1 && translation[0] !== '' && translation[1] !== '') {
+ word = word.replace(new RegExp(translation[0], 'g'), translation[1]);
+ }
+ });
+ return word;
+}
+
export function parseReferences(detailsMarkdown) {
const references = detailsMarkdown.match(/\{\{.+?\}\}/g);
if (references && Array.isArray(references)) {
new Set(references).forEach(reference => {
let wordToFind = reference.replace(/\{\{|\}\}/g, '');
let homonymn = 0;
-
+
if (wordToFind.includes(':')) {
const separator = wordToFind.indexOf(':');
homonymn = wordToFind.substr(separator + 1);
@@ -46,7 +56,7 @@ export function parseReferences(detailsMarkdown) {
homonymn = 1;
}
const homonymnSubHTML = homonymn > 0 ? '' + homonymn.toString() + '' : '';
- const wordMarkdownLink = `[${wordToFind}${homonymnSubHTML}](#${existingWordId})`;
+ const wordMarkdownLink = `[${translateOrthography(wordToFind)}${homonymnSubHTML}](#${existingWordId})`;
detailsMarkdown = detailsMarkdown.replace(new RegExp(reference, 'g'), wordMarkdownLink);
}
});
diff --git a/src/js/wordManagement.js b/src/js/wordManagement.js
index a192346..e037beb 100644
--- a/src/js/wordManagement.js
+++ b/src/js/wordManagement.js
@@ -91,7 +91,7 @@ export function parseReferences(detailsMarkdown) {
homonymn = 1;
}
const homonymnSubHTML = homonymn > 0 ? '' + homonymn.toString() + '' : '';
- const wordMarkdownLink = `[${translateOrthography(wordToFind)}${homonymnSubHTML}](#${existingWordId})`;
+ const wordMarkdownLink = `[${translateOrthography(wordToFind)}${homonymnSubHTML}](#${existingWordId})`;
detailsMarkdown = detailsMarkdown.replace(new RegExp(reference, 'g'), wordMarkdownLink);
}
});