openedx / openedx/docs.openedx.org

Allow for sematic url for i18n

Open
#126 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build-issue i18n translators
Dominant language
JavaScript
Stars
35
Forks
95
Avg merge
5d 15h
Merged PRs (30d)
3

Description

The Problem:

Right now the doc default url is https://docs.openedx.org/en/latest/* this would default en lang. However when changing the langauge using transifex selector lang it would change the cotent to the selected langauge, however the url would always contain en. This has the following downside:

  • The url is not semantic and is incorrect (in case user picked a different lang than en)
  • There isn't a mechanism to generate links for different lang code to force the docs site show content in a spesfic language.

Suggested Solutions

The good news is TX could view translated content if code exits in url; as per doc it can detect lang code in path i.e. /ar/ or in query params i.e ?lang=ar. However for this to work, from TX side we need enable lang detect which is a simple configuration can be added in this context : https://github.com/openedx/docs.openedx.org/blob/1e4c1adf38fd49ad99cba7582cfdbd14f25d764c/source/_templates/layout.html#L4-L7
We would have something like:

<script type="text/javascript">
    window.liveSettings = {
        api_key: "7af91b0a80054fab9de5fad172a25171",
         detectlang: true // This option can also be a function which should return the lang-code refer to refs below
    };

From readthedocs prespective (I am speculating here), to allow such featuer integration to work as expected, we would probably need to choose from the following options:

  • Remove /en/ part of the url (so then if we want to link a spesfic lang of the doc: we would just add ?lang=lang_code in the end of the url.
  • Allow readthedocs for whatever lang code exits in url to just serve the default page. i.e.
    • For url https://docs.openedx.org/en/latest/* TX JS wouldn't do anything
    • For url https://docs.openedx.org/ar/latest/*TX JS would mutate the DOM and show arabic version.

For second option above; since TX works in JS level (it mutate the dom content), it doesn't matter if Readthedocs would always serve english version for whatever code exits in the url. The caveate for this apporach is SEO, however SEO bots/indexer do run JS code , but of course to ensure we get the right langauge is being index we could consider prerender the site in different langauges (see ref 3), but then that might require more complex readthedocs configuration/integration. Although I don't know how important SEO is for doc site, I can nonetheless recommand if SEO is imporant for whichever approach we choose, someone would need to register the domain docs.openedx.org in Google search console so that we are confident content per langague are correrctly indexed.

How would this relate to bigger project:

Once this is resolved, in the context where the platform direct to extenral documenation source, we could direct learner/course author to the correct version of the doc that matches their language in account settings. Instead to just have hardcoded link to English.

I think this topic was once raised in TWG, to ensure the platform offers a consistent i18n experience. One blocker at that time was that docs is only available in en, but since its available in multiple lang and assuming this issue would be resolved. Then the last requirment to allow such expirence should be trivial or at least. We would need to ensure first for whatever external help url used, it should have a page/resource exits in this project and developer would be asked to add lang_code in the url.

Refs:

  1. https://docs.transifex.com/live/webmasters
  2. https://docs.transifex.com/live/api
  3. https://docs.transifex.com/live/seo-guide#javascript-and-seo-concerns

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with source/_templates/layout.html and the Transifex Live webmaster and SEO references linked in the issue. Clarify whether language should be represented in the path or query string, and verify how Read the Docs handles those URLs. Done means an agreed, tested URL strategy that shows the selected language and supports language-specific documentation links.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation, internationalization, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.