Skip to content

activist-org/i18n-check-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18n check logo

issues python license coc matrix

A GitHub action to check i18n/L10n keys and values

i18n-check-action is a GitHub action for i18n-check used to automate the validation of keys and values of your internationalization and localization processes.

Developed by the activist community, this action is meant to assure that development and i18n/L10n teams are in sync when using JSON based localization processes. The action can be expanded later to work for other file type processes as needed.

Note

For the Python package please see activist-org/i18n-check.

Contents

Conventions

activist i18n keys follow the following conventions that are enforced by i18n-check:

  • All key base paths should be the file path where the key is used
  • If a key is used in more than one file, then the lowest common directory followed by _global is the base path
  • Base paths should be followed by a minimally descriptive content reference
    • Only the formatting of these content references is checked via i18n-check
  • Separate base directory paths by periods (.)
  • Separate all directory and file name components as well as content references by underscores (_)
  • Repeat words in file paths for sub directory organization should not be repeated in the key

Note

An example valid key is:

Key: "components.component_name.CONTENT_REFERENCE"

File: components/component/ComponentName.ext

How it works

Arguments

You provide i18n-check-action with the following arguments:

  • src-dir: The path to the directory that has source code to check
  • i18n-dir: The directory path to your i18n files
  • i18n-src: The name of the i18n source file
  • i18n-map: The path to the i18n-map file (optional - see i18n-check)

Checks

From there the following checks are ran across your codebase:

  • key_identifiers: Does the source file have keys that don't match the above format or name conventions?
    • Rename them so i18n key usage is consistent and their scope is communicated in their name.
  • unused_keys: Does the source file have keys that are not used in the codebase?
    • Remove them so the localization team isn't working on strings that aren't used.
  • non_source_keys: Do the target locale files have keys that are not in the source file?
    • Remove them as they won't be used in the application.
  • repeat_values: Does the source file have repeat values that can be combined into a single key?
    • Combine them so the localization team only needs to localize one of them.
  • map_object: Do the i18nMap object keys match the i18n-src keys.
    • Make sure that the key map object is up to date if using i18nMap (see i18n-check).

Each of the above checks is ran in parallel with directions for how to fix the i18n files being provided when errors are raised. Checks can also be disabled in the workflow via options passed in the configuration YAML file.

Configuration

To use this action, make a file .github/workflows/i18n-check.yml and include the following template configuration:

name: i18n-check

on:
  pull_request:
  push:
    branches: [opened, reopened, synchronize]
    paths:
      - "**/SOURCE_I18N_FILE"

  push:
    branches:
      - main
    paths:
      - "**/SOURCE_I18N_FILE"

jobs:
  i18n-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
      - uses: activist/i18n-check-action@v1
        with:
          src-dir: PATH_TO_CODE_TO_CHECK
          i18n-dir: PATH_TO_I18N_FILES
          i18n-src: PATH_TO_SOURCE_I18N_FILE
          i18n-map: PATH_TO_I18N_MAP_FILE

Contributors

Thanks to all our amazing contributors! ❤️