Hacktoberfest Participants Help Us Internationalize the user-statistician GitHub Action
Tags: hacktoberfest, showdev, github, webdev
Published: 2021-09-29 15:54:00

A few months ago, I released a GitHub Action, [user-statistician](https://github.com/cicirello/user-statistician), that generates a detailed GitHub stats SVG entirely within GitHub Actions. It generates a detailed visual summary of your activity on GitHub, such as your contributions, distribution of programming languages within your public repositories, etc, suitable to display on your [GitHub Profile README](https://docs.github.com/en/github/setting-up-and-managing-your-github-profile/customizing-your-profile/managing-your-profile-readme). It can also be customized in various ways. We are now specifically interested in increasing international support by adding translations for other languages. The action currently has built-in support for English, Italian, and German. We would like to expand upon this. Check out the GitHub repository for details:

{% github cicirello/user-statistician %}

You can also find more information about user-statistician in our prior post on Dev.to:

{% link https://dev.to/cicirello/generate-a-github-stats-svg-for-your-github-profile-readme-in-github-actions-1iaj %}

## Table of Contents
* [Hacktoberfest Issues](#hacktoberfest-issues): About the Hacktoberfest labeled issues related to adding support for additional languages.
* [Samples](#samples): A few samples in the currently supported languages, and for a couple different color options.
* [How to Try Out the Action](#how-to-try-out-the-action): Example workflow to help you try out the action.
* [More Examples](#more-examples): Information on additional examples provided in the GitHub repository.

## Hacktoberfest Issues

Initially, it supported only English. However, recently a couple first time contributors translated the various headings and labels into Italian and German. We are interested in further expanding international support by providing additional language options. This is ideal for a first-time contributor as all necessary changes to add support for a new locale are contained in a single source code file, enabling you to easily gain experience in submitting a pull request, having it reviewed, etc. The programming skill level necessary to add support for a new locale is also at the beginning level. Project is implemented in Python and the strings for the various labels are defined within a couple Python dict objects, so adding support for a locale primarily involves adding some entries to a couple Python dictionaries.

To contribute a language translation, all necessary changes involve only editing the file [src/StatConfig.py](https://github.com/cicirello/user-statistician/blob/main/src/StatConfig.py).

There are currently a few [open issues for specific languages](https://github.com/cicirello/user-statistician/issues?q=is%3Aissue+is%3Aopen+label%3A%22Hacktoberfest%22). But we are open to adding support for any language where there is interest. So if you'd like to contribute a language translation for one not accounted for by one of the open issues, feel free to start by submitting an issue so that we are aware of the language you have interest in contributing, and then follow that with a pull request.

## Samples

The user-statistician GitHub Action has a few different built-in themes (light, dark, and dark-dimmed), and also supports custom user-defined colors. Here are a few examples, including of the existing locales.

This first sample is for the default English, and uses the custom color option to [match the color palette of my personal website](https://www.cicirello.org/software/#ghstats):

![Sample with custom colors and default locale en](https://raw.githubusercontent.com/cicirello/status/main/images/userstats.svg)

This next example is for Italian (locale: it), and uses the built-in dark theme:

![Sample with dark theme and locale it](https://raw.githubusercontent.com/cicirello/user-statistician/samples/images/it.svg)

This third example is for German (locale: de), and uses the built-in light theme:

![Sample with light theme and locale de](https://raw.githubusercontent.com/cicirello/user-statistician/samples/images/de.svg)

Check out my [GitHub Profile](https://github.com/cicirello) for an additional live example, which uses the built-in dark theme.

## How to Try Out the Action

If you want to try the action out, just drop the following workflow into a file with the name "user-statistician.yml" in the ".github/workflows" directory of your profile repository (or technically any repository that you own). It uses all of the action's default settings, and which runs the action daily on a schedule, and every time the workflow itself is changed (assumes the workflow file name is "user-statistician.yml").

```YAML
name: user-statistician

on:
  schedule:
    - cron: '0 3 * * *'
  push:
    branches: [ main ]
    paths: [ '.github/workflows/user-statistician.yml' ]
  workflow_dispatch:

jobs:
  stats:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Generate the user stats image
      uses: cicirello/user-statistician@v1
      env:
        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
```

The above uses all of the defaults (light theme, English, etc). See the GitHub repository for details on the available inputs. If you want to change the locale, you can do so as follows (example sets locale for Italian):

```YAML
name: user-statistician

on:
  schedule:
    - cron: '0 3 * * *'
  push:
    branches: [ main ]
    paths: [ '.github/workflows/user-statistician.yml' ]
  workflow_dispatch:

jobs:
  stats:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Generate the user stats image
      uses: cicirello/user-statistician@v1
      with:
        locale: it
      env:
        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
```

In both cases above, the default filename and location are used for the image (which can be changed with action inputs). Assuming the default filename and location, you can then link to the image in your GitHub README with the following markdown:

```markdown
![My GitHub Activity](images/userstats.svg)
```

## More Examples

Setting up and configuring the action is easy. The GitHub repository has a [quickstart](https://github.com/cicirello/user-statistician/tree/main/quickstart) directory containing several ready-to-use workflows to get you started. Pick one, download it, commit it to the `.github/workflows` directory of your profile's repository, and add a link to the generated image in your README. The quickstart workflows are configured to run nightly on a schedule, on pushes of the workflow file, as well as on `workflow_dispatch` events (so you can run it manually if need be).