Skip to content

Commit

Permalink
fix GitHub translation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow committed Jun 11, 2024
1 parent b53e73e commit c70570f
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions overrides/assets/javascripts/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,15 @@ const gmcTranslateButton = () => {
const newFileName = oldFileName.replace(".md", `.${gGMC_PAGE_LOCALE}.md`);
const topDirectory = hrefParts.pop();
const newURLBase = hrefParts.join("/").replace("/edit/", "/new/");
const fileNameParam = encodeURIComponent(`${topDirectory}/${newFileName}`);
const fileNameParam = encodeURIComponent(newFileName);
const indexFileHint = oldFileName === "index.md" ? `In case of \`index.md\`, yes, keep the \`${topDirectory}/\` part in the commit message.\n` : "";
const messageFileName = oldFileName === "index.md" ? `${topDirectory}/index.md` : oldFileName;
const messageRaw = `Add \`${gGMC_PAGE_LOCALE}\` translation for \`${messageFileName}\``;
const messageRawEscaped = messageRaw.replaceAll("`", "\\`");
const messageParam = encodeURIComponent(messageRaw);
const valueParam = encodeURIComponent([
"Open the `Preview` tab to display with better formatting.",
"## Overview",
"# :information_source: Overview",
"This method of translation is for those that don't want to set up the project files.",
"Due to technical limitations you need to copy the English base contents yourself.",
"Before you do that please make sure that:",
Expand All @@ -382,37 +382,26 @@ const gmcTranslateButton = () => {
"- `Spaces` and `4` are selected in the upper right corner of the editor in the `Edit` tab,",
"- you've read our [contribution guidelines](https://gothic-modding-community.github.io/gmc/contribute/).",
"",
"---",
"",
":exclamation: :warning: :exclamation:",
"",
"The file name and commit message should be already set, however due to the new GitHub UI the behavior has changed.",
"Assure that:",
`- the file name above is set to \`${newFileName}\` without the \`${topDirectory}/\` part in the \`Edit\` tab,`,
`- before committing changes, the message is set to: **${messageRawEscaped}**`,
`It will later look like this: ${messageRaw}`,
indexFileHint,
":exclamation: :warning: :exclamation:",
"## :gb: English File",
`[![](https://img.shields.io/badge/Open%20English%20File-Here-blue?style=for-the-badge&logo=libreofficewriter)](${anchor.href.replace("/edit/", "/raw/")})`,
"Copy the contents and in the `Edit` tab, replace these instructions with them.",
"",
"---",
"",
"### English File",
"Here is the link to the English file:",
anchor.href.replace("/edit/", "/raw/"),
"Copy the contents and in the `Edit` tab, replace these instructions with them.",
"### :heavy_check_mark: Correct Commit Message",
`Please name your commit: **${messageRawEscaped}**`,
"Due to technical limitations it has to be set manually.",
"",
"#### Hint",
"### :bulb: Hint",
"*Please note that this page **won't** preserve your changes in real time like Google Docs.*",
"*Until you `Commit` the changes using the green button nothing will be saved, so be sure not to lose progress.*",
"",
"#### Hint",
"*GitHub's file editor doesn't provide `.md` formatting options, if you want those, consider using https://stackedit.io/*",
"### :bulb: Hint",
"*GitHub's file editor doesn't provide `.md` formatting options, if you want those, consider using https://stackedit.io/ or your local editor like VS Code.*",
].join(" \n"));
const newAnchor = document.createElement("a");
newAnchor.id = "gmc-new-translation-button";
newAnchor.classList = anchor.classList;
// Weird quirk. The topDirectory needs to be in both, the link and in the filename param to put the file in the correct directory.
// -- This quirk stopped quirking with the introduction of the new GitHub UI, sadge.
newAnchor.href = `${newURLBase}/${topDirectory}?filename=${fileNameParam}&message=${messageParam}&value=${valueParam}`;
newAnchor.innerHTML = gGMC_TRANSLATE_SVG;
newAnchor.title = gGMC_TRANSLATE_CTA;
Expand Down

0 comments on commit c70570f

Please sign in to comment.