Search code examples
localizationechartsiso8601

How can I overwrite Echarts month abbreviation / locales


I want to modify the langDE-locales for echarts [1], as it does not follow ISO 8601 in german translation for march:

What is the best way to modify it directly in the chart object? My idea was to replace the monthAbbr Array directly in the object. I already made a pull request in the project, but this will take at least until the same release.

export default {
    time: {
        ...
        monthAbbr: [
            'Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun',
            'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'
        ],
      },
};

to

export default {
    time: {
        ...
        monthAbbr: [
            'Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun',
            'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'
        ],
      },
};

[1] https://github.com/apache/echarts/blob/release/src/i18n/langDE.ts

[2] https://github.com/datejs/Datejs/blob/master/build/date-de-DE.js#L9


Solution

  • The source shows "Mar" => This is the English abbreviation. Using "Mrz" for "März" would be the correct and is defined in ISO 8601 as you already pointed out.

    Ergo: This is a translation bug in the source. By opening the pull request, you stepped the right way to solve the issue.

    If you already have created a pull request, you also have a patch file. So if you can't wait, you can apply your (unofficial) patch to your copy of the source an use it.

    Like with every patch: Until the patch has become part of the official source, you potentially will have to apply your patch at every update of the software.

    The technically clear answer is: Change everything at the source as the developper of the code would/should do.

    Doing this is your right granted by "free" licenses like the "Apache License" of echarts. This is also one of the many reason, why such "free" licenses exist. And you have to fulfill the obligations:

    If you use the patched version in public

    • it must be clearly visible, that this is a patched version.
    • You also have to publish the new code under an appropriate license (probably done while the process of the pull request)

    else you would violate the echarts license and this is not necessarily for free anymore...