-
Notifications
You must be signed in to change notification settings - Fork 30
Add multilingual support for exercise descriptions and tips to be displayed in the exercise implementation #2928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| :root[lang="de"] .multilang:not([lang="de"]) { | ||
| display: none; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| :root[lang="en"] .multilang:not([lang="en"]) { | ||
| display: none; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
AutoPING-TUI marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Multilanguage Support for Exercises and Tips | ||
|
|
||
| This document provides an overview of how to support multilingual exercise descriptions and tips that are displayed in the exercise implementation view. | ||
|
|
||
| ## Introduction | ||
|
|
||
| To improve the maintenance of exercises in multilingual teaching scenarios, it may be better to provide exercises with exercise descriptions in several languages than to work with translated copies of an exercise. CodeOcean already has multilingual support that can be used to achieve this. | ||
|
|
||
| The implementation of multilanguage support in CodeOcean is inspired by [Moodle's Multilang Content Filter](https://docs.moodle.org/405/en/Multi-language_content_filter): Attributes are used to indicate the multilingual nature of a content element (`class="multilang"`) and to specify the exact language (`lang="XX"`). CSS is then used to control the visibility on the page. | ||
|
|
||
| ## Usage | ||
|
|
||
| When making exercise descriptions or tips multilingual, the `.multilang` class must be assigned to all multilingual content. The `lang` attribute must be set to the appropriate locale, e. g., `"en"` or `"de"`. This very simple solution can be applied in many different ways: | ||
|
|
||
| Example 1 (Separated Multilingual Content Blocks): | ||
|
|
||
| ```md | ||
| <p class="multilang" lang="de">Implementieren Sie eine Funktion, die für einen gegebenen Parameter entscheidet, ob er gerade oder ungerade ist.</p> | ||
| <p class="multilang" lang="en">Implement a function that decides for a given parameter whether it is even or odd.</p> | ||
| ``` | ||
|
|
||
| Example 2 (Inline Separation of Multilingual Content): | ||
|
|
||
| ```md | ||
| <p><span class="multilang" lang="de">Implementieren Sie eine Funktion, die für einen gegebenen Parameter entscheidet, ob er gerade oder ungerade ist.</span><span class="multilang" lang="en">Implement a function that decides for a given parameter whether it is even or odd.</span></p> | ||
| ``` | ||
|
|
||
| This approach also applies to the description of tips, including their example sections. | ||
|
|
||
| ## Supported Locales | ||
|
|
||
| At the time of writing CodeOcean supports the `DE` and `EN` locales. Accordingly, the two CSS snippets [`multilang_de.css`](../app/javascript/multilang_de.css) and [`multilang_en.css`](../app/javascript/multilang_en.css) have been added to the application. To support other locales, just copy and paste one of these snippets and change the locale in the CSS rule. To really take effect, the appropriate locale must be added to CodeOcean (see [Config --> Locales](../config/locales/) for details) and also requires a change to `Rails.application.config.i18n.available_locales` in [`config/application.rb`](../config/application.rb). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.