Skip to content

Commit

Permalink
Fix translations
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Mar 10, 2024
1 parent f10f09b commit 047ee56
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions website/src/components/CodeSnippet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,38 @@ export function trimSnippet(
line = line.substring(leadingSpaces.length);
}

if (translations) {
const templateMatch = templateRegex.exec(line);
const endTemplateMatch = endTemplateRegex.exec(line);
const templateMatch = templateRegex.exec(line);
const endTemplateMatch = endTemplateRegex.exec(line);

if (templateMatch) {
if (currentTemplateKey) {
throw new Error(
`Nested templates are not supported. Template ${currentTemplateKey} is already open (${templateMatch[1]})`
);
}

const templateKey = templateMatch[1];
if (templateMatch) {
if (currentTemplateKey) {
throw new Error(
`Nested templates are not supported. Template ${currentTemplateKey} is already open (${templateMatch[1]})`
);
}

const translation = translations[templateKey];
const templateKey = templateMatch[1];

if (translation) {
// Replace the content if the template is translated, and insert the new content.
currentTemplateKey = templateKey;
transformedLines.push(translation);
}
const translation = translations?.[templateKey];

// delete the template markup.
continue;
if (translation) {
// Replace the content if the template is translated, and insert the new content.
currentTemplateKey = templateKey;
transformedLines.push(translation);
}

if (endTemplateMatch) {
currentTemplateKey = undefined;
continue;
}
// delete the template markup.
continue;
}

// If inside a translation, delete the untranslated content.
if (currentTemplateKey) {
continue;
}
if (endTemplateMatch) {
currentTemplateKey = undefined;
continue;
}

// If inside a translation, delete the untranslated content.
if (currentTemplateKey) {
continue;
}

transformedLines.push(line);
Expand Down

0 comments on commit 047ee56

Please sign in to comment.