Skip to content

Tutorials: refactor tutorialStrings mapping #617

@musicEnfanthen

Description

@musicEnfanthen

The current structure of the tutorialStrings object in the mei-tutorials.js file is a two-level nested object where the first level keys are language codes ('EN', 'ES', etc.) and the second level keys are string identifiers ('codeNotWellformed', 'fetchOperationProblem', etc.). While this structure is clear and easy to understand, it could be improved for better scalability and maintainability.

CWe should consider refactoring the tutorialStrings object to a structure where each key is a string identifier and its value is another object that maps language codes to their translations. This would make it easier to add new languages or new strings in the future.

Current structure:

var tutorialStrings = {
    'EN': {
        'codeNotWellformed': 'Your code is not well-formed.',
        'fetchOperationProblem': There has been a problem with the fetch operation for:',
        // ...other strings...
    },
    'ES': {
        'codeNotWellformed': 'Su código no está bien formado.',
        'fetchOperationProblem': 'Ha habido un problema con la operación fetch para:'
        // ...other strings...
    }
    // ...other languages...
};

Proposed structure:

var tutorialStrings = {
    'codeNotWellformed': {
        'EN': 'Your code is not well-formed.',
        'ES': 'Su código no está bien formado.'
    },
    'fetchOperationProblem': {
        'EN': 'There has been a problem with the fetch operation for:',
        'ES': 'Ha habido un problema con la operación fetch para:'
    },
    // ...and so on for the rest of the strings
};

With this structure it is easier to add new laguages or strings.

Instead of using tutorialStrings[LANG][stringId], we would then use tutorialStrings[stringId][LANG] to get the correct value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Technical issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions