From f6f58a7d456b4f998e23013053a1c4e8daea83e7 Mon Sep 17 00:00:00 2001 From: Jonas Rittershofer Date: Sat, 31 Oct 2020 17:14:33 +0100 Subject: [PATCH 1/2] Support RTL-Languages Signed-off-by: Jonas Rittershofer Co-authored-by: Akam Foad --- config/i18next.config.js | 28 ++++++++++++++++------------ lib/build/build-helpers.js | 4 ++-- lib/i18n-translate.js | 18 +++++++++++++----- resources/layouts/challenge.hbs | 2 +- resources/layouts/page.hbs | 3 ++- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/config/i18next.config.js b/config/i18next.config.js index c4466c87..3315eecf 100644 --- a/config/i18next.config.js +++ b/config/i18next.config.js @@ -1,18 +1,22 @@ /** Configuration Settings for i18next */ -// Available appLanguages +/* Available appLanguages + * Each language is defined as an object per languageKey: + * The Object MUST contain a name-property, which will be shown in the dropdown-menu + * Optional Property "direction: 'rtl'" is used to mark right-to-left lanugages. + */ const appLanguages = { - 'en-US': 'English', - 'de-DE': 'Deutsch', - 'es-ES': 'Español', - 'fr-FR': 'Français', - 'ja-JP': '日本語', - 'ko-KR': '한국어', - 'ku': 'کوردی', - 'pl-PL': 'Polski', - 'pt-BR': 'Português Brasileiro', - 'uk-UA': 'Українська', - 'zh-TW': '中文(臺灣)', + 'en-US': { name: 'English' }, + 'de-DE': { name: 'Deutsch' }, + 'es-ES': { name: 'Español' }, + 'fr-FR': { name: 'Français' }, + 'ja-JP': { name: '日本語' }, + 'ko-KR': { name: '한국어' }, + 'ku': { name: 'کوردی', direction: 'rtl' }, + 'pl-PL': { name: 'Polski' }, + 'pt-BR': { name: 'Português Brasileiro' }, + 'uk-UA': { name: 'Українська' }, + 'zh-TW': { name: '中文(臺灣)' }, } const appLanguageKeys = Object.keys(appLanguages) diff --git a/lib/build/build-helpers.js b/lib/build/build-helpers.js index a9e76089..65c823d6 100644 --- a/lib/build/build-helpers.js +++ b/lib/build/build-helpers.js @@ -11,8 +11,8 @@ function getLocaleMenu () { const { appLanguages } = require('../../config/i18next.config') let localeMenu = '' - Object.entries(appLanguages).forEach(([languageKey, language]) => { - localeMenu = localeMenu.concat('') + Object.entries(appLanguages).forEach(([languageKey, languageObject]) => { + localeMenu = localeMenu.concat('') }) return localeMenu } diff --git a/lib/i18n-translate.js b/lib/i18n-translate.js index 73329e86..198e0578 100644 --- a/lib/i18n-translate.js +++ b/lib/i18n-translate.js @@ -8,6 +8,7 @@ */ const i18n = require('electron').remote.getGlobal('i18n') +const { appLanguages } = require('../config/i18next.config') // defaultOptions for interpolation const defaultOptions = { @@ -99,9 +100,16 @@ function insertBoxTranslationStyles () { document.styleSheets[sheetIndex].deleteRule(0) } - // Append new rules - document.styleSheets[sheetIndex].insertRule(".chal-goal.border-box::before {content: '" + i18n.t('Goal') + "';}", 0) - document.styleSheets[sheetIndex].insertRule(".chal-no-pass.border-box::before {content: '" + i18n.t("Didn't Pass?") + "';}", 0) - document.styleSheets[sheetIndex].insertRule(".chal-tip.border-box::before {content: '" + i18n.t('Tip') + "';}", 0) - document.styleSheets[sheetIndex].insertRule(".chal-step.border-box::before {content: '" + i18n.t('Step') + "';}", 0) + // Insert Style for right-to-left languages + if (appLanguages[i18n.language].direction === 'rtl') { + document.styleSheets[sheetIndex].insertRule('div.content {direction: rtl;}') + } + + // Append rules for challenge-boxes + if (document.styleSheets[sheetIndex].ownerNode.id === 'challenge-translation-style') { + document.styleSheets[sheetIndex].insertRule(".chal-goal.border-box::before {content: '" + i18n.t('Goal') + "';}") + document.styleSheets[sheetIndex].insertRule(".chal-no-pass.border-box::before {content: '" + i18n.t("Didn't Pass?") + "';}") + document.styleSheets[sheetIndex].insertRule(".chal-tip.border-box::before {content: '" + i18n.t('Tip') + "';}") + document.styleSheets[sheetIndex].insertRule(".chal-step.border-box::before {content: '" + i18n.t('Step') + "';}") + } } diff --git a/resources/layouts/challenge.hbs b/resources/layouts/challenge.hbs index 8bf21e01..79a5cff4 100644 --- a/resources/layouts/challenge.hbs +++ b/resources/layouts/challenge.hbs @@ -8,7 +8,7 @@ - + {{{ header }}} diff --git a/resources/layouts/page.hbs b/resources/layouts/page.hbs index 16f5ab15..ff22df50 100644 --- a/resources/layouts/page.hbs +++ b/resources/layouts/page.hbs @@ -6,12 +6,13 @@ + {{{ header }}} -
+
{{{ body }}}
From 6e8b2327e7e7cd6b560d9cd8e254c33775bb02b8 Mon Sep 17 00:00:00 2001 From: Jonas Rittershofer Date: Sat, 31 Oct 2020 18:31:57 +0100 Subject: [PATCH 2/2] Keep code-elements ltr Co-authored-by: Akam Foad Signed-off-by: Jonas Rittershofer --- assets/css/new-challenge.css | 5 ++ lib/i18n-translate.js | 2 + .../content/challenges/11_merge_tada.hbs | 20 +++---- resources/content/challenges/1_get_git.hbs | 8 +-- resources/content/challenges/2_repository.hbs | 14 ++--- .../content/challenges/3_commit_to_it.hbs | 18 +++--- resources/content/challenges/4_githubbin.hbs | 6 +- .../content/challenges/5_remote_control.hbs | 16 ++--- .../content/challenges/6_forks_and_clones.hbs | 14 ++--- .../7_branches_arent_just_for_birds.hbs | 32 +++++----- .../challenges/8_its_a_small_world.hbs | 2 +- .../challenges/9_pull_never_out_of_date.hbs | 8 +-- resources/content/pages/dictionary.hbs | 58 +++++++++---------- 13 files changed, 105 insertions(+), 98 deletions(-) diff --git a/assets/css/new-challenge.css b/assets/css/new-challenge.css index ba1c5235..9b50ac3a 100644 --- a/assets/css/new-challenge.css +++ b/assets/css/new-challenge.css @@ -177,6 +177,11 @@ gre7-border.border-box code { /* CODE STYLES -------------------------------------------------------------------------- */ + /* TODO needs some Cleanup, to have similar styling accros challenges and no doubled classes here! */ + +div.code { + padding-bottom: 4px; +} code { font-size: 0.8em; diff --git a/lib/i18n-translate.js b/lib/i18n-translate.js index 198e0578..b3eb0931 100644 --- a/lib/i18n-translate.js +++ b/lib/i18n-translate.js @@ -103,6 +103,8 @@ function insertBoxTranslationStyles () { // Insert Style for right-to-left languages if (appLanguages[i18n.language].direction === 'rtl') { document.styleSheets[sheetIndex].insertRule('div.content {direction: rtl;}') + // Code-Elements should stay ltr + document.styleSheets[sheetIndex].insertRule('div.code {direction: ltr;}') } // Append rules for challenge-boxes diff --git a/resources/content/challenges/11_merge_tada.hbs b/resources/content/challenges/11_merge_tada.hbs index d613d27b..07032382 100644 --- a/resources/content/challenges/11_merge_tada.hbs +++ b/resources/content/challenges/11_merge_tada.hbs @@ -13,16 +13,16 @@

-

git checkout gh-pages

+
git checkout gh-pages

-

git merge <BRANCHNAME>

+
git merge <BRANCHNAME>

-

git branch -d <BRANCHNAME>

+
git branch -d <BRANCHNAME>

-

git push <REMOTENAME> --delete <BRANCHNAME>

+
git push <REMOTENAME> --delete <BRANCHNAME>
@@ -30,7 +30,7 @@

-

git pull upstream gh-pages

+
git pull upstream gh-pages
@@ -50,14 +50,14 @@
  • - git merge <BRANCHNAME> +
    git merge <BRANCHNAME>
  • - git checkout <BRANCHNAME> +
    git checkout <BRANCHNAME>
  • - git branch -d <BRANCHNAME> +
    git branch -d <BRANCHNAME>
  • - git push <REMOTENAME> --delete <BRANCHNAME> +
    git push <REMOTENAME> --delete <BRANCHNAME>
  • - git pull <REMOTENAME> <BRANCHNAME> +
    git pull <REMOTENAME> <BRANCHNAME>
diff --git a/resources/content/challenges/1_get_git.hbs b/resources/content/challenges/1_get_git.hbs index 36083590..fa2f87c4 100644 --- a/resources/content/challenges/1_get_git.hbs +++ b/resources/content/challenges/1_get_git.hbs @@ -48,17 +48,17 @@

-

git --version

+
git --version

-

git version 1.9.1

+
git version 1.9.1

-

git config --global user.name "Your Name"

+
git config --global user.name "Your Name"

-

git config --global user.email "youremail@example.com"

+
git config --global user.email "youremail@example.com"

diff --git a/resources/content/challenges/2_repository.hbs b/resources/content/challenges/2_repository.hbs index 9b9b08a0..811fcdc4 100644 --- a/resources/content/challenges/2_repository.hbs +++ b/resources/content/challenges/2_repository.hbs @@ -37,14 +37,14 @@


- mkdir hello-world +
mkdir hello-world


- cd hello-world +
cd hello-world

- git init +
git init

@@ -57,12 +57,12 @@
  • - mkdir <FOLDERNAME> +
    mkdir <FOLDERNAME>
  • - cd <FOLDERNAME> +
    cd <FOLDERNAME>
  • - ls +
    ls
  • - git init +
    git init
diff --git a/resources/content/challenges/3_commit_to_it.hbs b/resources/content/challenges/3_commit_to_it.hbs index 5bcdca9e..86497cf8 100644 --- a/resources/content/challenges/3_commit_to_it.hbs +++ b/resources/content/challenges/3_commit_to_it.hbs @@ -21,16 +21,16 @@

-

git status

+
git status

-

git add readme.txt

+
git add readme.txt

-

git commit -m "Created readme"

+
git commit -m "Created readme"
@@ -42,7 +42,7 @@

-

git diff

+
git diff

@@ -52,14 +52,14 @@
  • -
  • git status
  • +
    git status
  • -
  • git diff
  • +
    git diff
  • -
  • git add <FILENAME>
  • +
    git add <FILENAME>
  • -
  • git add .
  • +
    git add .
  • -
  • git commit -m "your commit message"
  • +
    git commit -m "your commit message"
diff --git a/resources/content/challenges/4_githubbin.hbs b/resources/content/challenges/4_githubbin.hbs index ce3ef13c..fb2bc870 100644 --- a/resources/content/challenges/4_githubbin.hbs +++ b/resources/content/challenges/4_githubbin.hbs @@ -26,10 +26,10 @@ i18n-data="ch04~Add your GitHub username to your Git configuration. We'll do this just for the sake of Git-it{/smc/} it makes it easier to verify the upcoming challenges. Save it exactly as you created it on GitHub and {/str/}capitalize where capitalized{/str_e/}. Note, you don't need to enter the {/dqm/}{/lt/}{/dqm/} and {/dqm/}{/gt/}{/dqm/}.">

- git config --global user.username <UserName> +
git config --global user.username <UserName>

- git config --global user.username +
git config --global user.username
{{{ verify_button }}} @@ -44,6 +44,6 @@

-

git config --global user.username <UserName>

+
git config --global user.username <UserName>

diff --git a/resources/content/challenges/5_remote_control.hbs b/resources/content/challenges/5_remote_control.hbs index 299498e5..d46c68c0 100644 --- a/resources/content/challenges/5_remote_control.hbs +++ b/resources/content/challenges/5_remote_control.hbs @@ -57,7 +57,7 @@ i18n-data="ch05~Back in your terminal, and inside of the 'hello-world' folder that you initialized as a Git repository in the earlier challenge, you want to tell Git to remember the address of the remote version on GitHub's servers. You can have multiple remotes so each requires a name. The primary remote is typically named {/cde/}origin{/cde_e/}.">

- git remote add origin <URLFROMGITHUB> +
git remote add origin <URLFROMGITHUB>

@@ -67,7 +67,7 @@

- git remote set-url origin <URLFROMGITHUB> +
git remote set-url origin <URLFROMGITHUB>
@@ -80,7 +80,7 @@ i18n-data="ch05~Git has a branching system so that you can work on different parts of a project at different times. We'll learn more about that later, but by default the first branch is named 'master'. When you push (and later pull) from a project, you tell Git the {/str/}branch name{/str_e/} you want and the name of the {/str/}remote{/str_e/} that it lives on.">

- git push origin master +
git push origin master

@@ -91,14 +91,14 @@
  • - git remote add <REMOTENAME> <URL> +
    git remote add <REMOTENAME> <URL>
  • - git remote set-url <REMOTENAME> <URL> +
    git remote set-url <REMOTENAME> <URL>
  • - git pull <REMOTENAME> <BRANCHNAME> +
    git pull <REMOTENAME> <BRANCHNAME>
  • - git remote -v +
    git remote -v
  • - git push <REMOTENAME> <BRANCH> +
    git push <REMOTENAME> <BRANCH>
diff --git a/resources/content/challenges/6_forks_and_clones.hbs b/resources/content/challenges/6_forks_and_clones.hbs index 4bf21b29..6531e91e 100644 --- a/resources/content/challenges/6_forks_and_clones.hbs +++ b/resources/content/challenges/6_forks_and_clones.hbs @@ -36,13 +36,13 @@


-

cd ..

+
cd ..

-

git clone <URLFROMGITHUB>

+
git clone <URLFROMGITHUB>

-

cd patchwork

+
cd patchwork

@@ -59,7 +59,7 @@

-

git remote add upstream https://github.com/jlord/patchwork.git

+
git remote add upstream https://github.com/jlord/patchwork.git

@@ -70,10 +70,10 @@
  • -
  • git remote add <REMOTENAME> <URL>
  • +
    git remote add <REMOTENAME> <URL>
  • -
  • git remote set-url <REMOTENAME> <URL>
  • +
    git remote set-url <REMOTENAME> <URL>
  • -
  • git remote -v
  • +
    git remote -v
diff --git a/resources/content/challenges/7_branches_arent_just_for_birds.hbs b/resources/content/challenges/7_branches_arent_just_for_birds.hbs index 0915a4f5..0aa89354 100644 --- a/resources/content/challenges/7_branches_arent_just_for_birds.hbs +++ b/resources/content/challenges/7_branches_arent_just_for_birds.hbs @@ -26,7 +26,7 @@ "lnk_pages": "http://pages.github.com" }'>

- http://githubusername.github.io/repositoryname +
http://githubusername.github.io/repositoryname
@@ -43,14 +43,14 @@ "add_jlord": "{/dqm/}add-jlord{/dqm/}" }'>

-

git branch <BRANCHNAME>

+
git branch <BRANCHNAME>

-

git checkout <BRANCHNAME>

+
git checkout <BRANCHNAME>
@@ -76,13 +76,13 @@

-

git status

-

git add <contributors/FILENAME>

-

git commit -m "commit message"

+
git status
+
git add <contributors/FILENAME>
+
git commit -m "commit message"

-

git push origin <BRANCHNAME>

+
git push origin <BRANCHNAME>
{{{ verify_directory_button }}} @@ -106,28 +106,28 @@

-

git add -A

-

git commit -m "move file into contributors folder"

+
git add -A
+
git commit -m "move file into contributors folder"

-

git branch -m <NEWBRANCHNAME>

+
git branch -m <NEWBRANCHNAME>

  • -
  • git checkout -b <BRANCHNAME>
  • +
    git checkout -b <BRANCHNAME>
  • -
  • git branch <BRANCHNAME>
  • +
    git branch <BRANCHNAME>
  • -
  • git checkout <BRANCHNAME>
  • +
    git checkout <BRANCHNAME>
  • -
  • git branch
  • +
    git branch
  • -
  • git branch -m <NEWBRANCHNAME>
  • +
    git branch -m <NEWBRANCHNAME>
  • -
  • git status
  • +
    git status
diff --git a/resources/content/challenges/8_its_a_small_world.hbs b/resources/content/challenges/8_its_a_small_world.hbs index a2aefe5f..72c5e04f 100644 --- a/resources/content/challenges/8_its_a_small_world.hbs +++ b/resources/content/challenges/8_its_a_small_world.hbs @@ -25,7 +25,7 @@

- https://github.com/YOURUSERNAME/patchwork/settings/access +
https://github.com/YOURUSERNAME/patchwork/settings/access
{{{ verify_button }}} diff --git a/resources/content/challenges/9_pull_never_out_of_date.hbs b/resources/content/challenges/9_pull_never_out_of_date.hbs index d8636e5a..1c52affc 100644 --- a/resources/content/challenges/9_pull_never_out_of_date.hbs +++ b/resources/content/challenges/9_pull_never_out_of_date.hbs @@ -15,7 +15,7 @@

-

git pull <REMOTENAME> <BRANCHNAME>

+
git pull <REMOTENAME> <BRANCHNAME>

@@ -27,10 +27,10 @@
  • - git status +
    git status
  • - git pull <REMOTENAME> <REMOTEBRANCH> +
    git pull <REMOTENAME> <REMOTEBRANCH>
  • - git fetch --dry-run +
    git fetch --dry-run
diff --git a/resources/content/pages/dictionary.hbs b/resources/content/pages/dictionary.hbs index 388781da..e550980b 100644 --- a/resources/content/pages/dictionary.hbs +++ b/resources/content/pages/dictionary.hbs @@ -4,11 +4,11 @@
  • - mkdir <FOLDERNAME> +
    mkdir <FOLDERNAME>
  • - cd <FOLDERNAME> +
    cd <FOLDERNAME>
  • - ls +
    ls
@@ -16,13 +16,13 @@
  • - git --version +
    git --version
  • - git config --global user.name "Your Name" +
    git config --global user.name "Your Name"
  • - git config --global user.email youremail@example.com +
    git config --global user.email youremail@example.com
  • - git config --global user.username uSeRnAmE +
    git config --global user.username uSeRnAmE
@@ -30,20 +30,20 @@
  • - git init +
    git init
  • - git status +
    git status
  • - git diff +
    git diff
  • - git add <FILENAME> +
    git add <FILENAME>
  • - git add . +
    git add .
  • - git commit -m "your commit message" +
    git commit -m "your commit message"
  • - git clone <URL> +
    git clone <URL>
@@ -51,15 +51,15 @@
  • - git branch <BRANCHNAME> +
    git branch <BRANCHNAME>
  • - git checkout <BRANCHNAME> +
    git checkout <BRANCHNAME>
  • - git checkout -b <BRANCHNAME> +
    git checkout -b <BRANCHNAME>
  • - git branch +
    git branch
  • - git branch -m <NEWBRANCHNAME> +
    git branch -m <NEWBRANCHNAME>
@@ -67,11 +67,11 @@
  • - git remote add <REMOTENAME> <URL> +
    git remote add <REMOTENAME> <URL>
  • - git remote set-url <REMOTENAME> <URL> +
    git remote set-url <REMOTENAME> <URL>
  • - git remote -v +
    git remote -v
@@ -79,11 +79,11 @@
  • - git pull +
    git pull
  • - git pull <REMOTENAME> <REMOTEBRANCH> +
    git pull <REMOTENAME> <REMOTEBRANCH>
  • - git fetch --dry-run +
    git fetch --dry-run
@@ -91,9 +91,9 @@
  • - git push <REMOTENAME> <BRANCHNAME> +
    git push <REMOTENAME> <BRANCHNAME>
  • - git merge <BRANCHNAME> +
    git merge <BRANCHNAME>
@@ -101,8 +101,8 @@
  • - git branch -D <BRANCHNAME> +
    git branch -D <BRANCHNAME>
  • - git push <REMOTENAME> --delete <BRANCHNAME> +
    git push <REMOTENAME> --delete <BRANCHNAME>