Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jemikanegara committed May 28, 2024
1 parent d881707 commit 22c9195
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,16 @@ function updateNode(node, language, type = "text") {
console.log("node.textContent mergedSplitted", mergedSplitted)

const mergedOrphanString = mergedSplitted.reduce((acc, curr, index) => {
const findTranslationKey = Object.entries(translatedMap).find(([key, value]) => curr.includes(value))?.[0];
const findTranslationKey = Object.entries(translatedMap).find(([key, value], ) => {
const isFirstIndex = index == 0;
const isLastIndex = index == mergedSplitted.length - 1;
const isFirstOrLast = isFirstIndex || isLastIndex;

// trim first or last because sometimes the translation key has extra space but the full translation doesn't have it
const valueToCompare = isFirstOrLast ? value.trim() : value;
const matched = curr.includes(valueToCompare);
return matched;
})?.[0];
// console.log("node.textContent findTranslationKey", findTranslationKey)
if (!findTranslationKey) {
return [
Expand Down

0 comments on commit 22c9195

Please sign in to comment.