question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crowdin Translation Download messes front matter

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I am currently integrating Crowdin translations into my project’s docs.

After running the following:

yarn run write-translations
yarn run crowdin upload
yarn run crowdin download

The translated sidebar_labels have a different formatting than the original docs.

For example, we expect the markdown format to be:

---
sidebar_label : Aperçu
---

in the translated docs but instead we get:

- - -
sidebar_label : Aperçu
- - -

Which messes up the rendering as can be seen here: Screen Shot 2022-10-24 at 2 14 21 PM

Reproducible demo

No response

Steps to reproduce

  1. Follow the guidelines here: https://docusaurus.io/docs/i18n/crowdin
  2. After generating translations, the sidebar_label surrounding dashes add an extra space between them, messing up the rendering.

Expected behavior

---
sidebar_label : Aperçu
---

Actual behavior

- - -
sidebar_label : Aperçu
- - -

Your environment

It is not live, we are testing it on a branch with no code modifications, just testing the crowdin integration.

Self-service

  • I’d be willing to fix this bug myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, Oct 24, 2022

From my experience, this is a very annoying Crowdin bug. Our website used to have the exact same issue. AFAICT, this is caused by Crowdin treating “Markdown with front matter” and “Markdown without front matter” as two separate file types, so if you uploaded a Markdown file and added front matter later, that front matter would be recognized as part of the content, so it becomes two separators (as --- is the syntax for separators). Similarly, if you uploaded a Markdown file with front matter and later removed it, Crowdin would literally break. Last time I contacted them:

image

…here was the response (for the latter issue, not the one you are reporting):


2. In case you’d like to update the using-plugins.md file with no front matter (as you showed us previously), it’d be required to have Project Manager’s access. The file could be updated in UI in the Content → Files tab, here’s a short guide (Proofreaders cannot access this tab): https://support.crowdin.com/files-management/?q=update#updating-source-files

If the file is indicated in the config file, it’s totally possible to update it via CLI as well with the “crowdin upload sources” or “crowdin push” commands, but still it’s required to do so via the Project Manager’s account.

Once the source file will be updated in the Content tab→ Files, the front matter for the file will be removed from the Crowdin project.

4. Also, in case you’d like to automatically update the files in the Crowdin project (once you change the fronts or anything else), we also have an option to connect the repository directly with the Crowdin project. Here’s a short guide: https://support.crowdin.com/github-integration/?q=github

The GitHub integration has a sync schedule based on which, the source files and translations will be automatically updated (sources in project, translations in the repo).


Great, currently re-upload is the only good way to switch the file type in the project (file type is set when the source file is uploaded).

There was a plan to deactivate automatic translations import from GitHub (especially if we talk about Markdown or HTML files), hope that will be introduced a bit later this year 🤞Hope we can remove that scary warning after that 😃


TL;DR: try re-uploading the file through the Crowdin UI instead of the CLI.

0reactions
YazzyYazcommented, Nov 2, 2022

@Josh-Cena @slorber I was able to fix the issue with a script:

#!/bin/bash
cd i18n
find . -type f -name "*.md" -exec sed -i 's/- - -/---/g' {} +
find . -type f -name "*.mdx" -exec sed -i 's/- - -/---/g' {} +

And then call this script after you run yarn crowdin:sync and before you call the yarn build command. Resolved the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Downloading Translations | Crowdin Documentation
You can download translations for the whole project at once or for separate files. Translations will be downloaded according to the export settings ......
Read more >
Downloading Translations - Crowdin Documentation
You can download translations for the whole project at once or for separate files. Translations will be downloaded according to the settings configured...
Read more >
Advanced Project Setup | Crowdin Documentation
Project owner and managers can always download sources and upload translations, not depending on the option status. Allow proofreaders to access hidden strings...
Read more >
Project Settings | Crowdin Documentation
If the option Save context information in the files is enabled, the context and max.length added in Crowdin Enterprise will be visible in...
Read more >
Offline Translation | Crowdin Documentation
You can download each file separately (in original or XLIFF format), download filtered strings (in XLIFF format), or download all files for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found