Skip to content

Validate your String Catalogs. Release with confidence that your app is properly translated!

License

Notifications You must be signed in to change notification settings

nicorichard/xcstringslint

Repository files navigation

xcstringslint

Setup deterministic validation of your app's .xcstrings string catalogs.

Ensure your string catalog changes are always up-to-snuff with your team's localization requirements.

Usage

Running

CLI

With a config file located in the same directory as the executable

swift run xcstringslint Sources/StringCatalogValidator/Resources/Localizable.xcstrings

To specify a config file append --config [config file path]

GitHub Actions

See this repository's actions for an example

Configuration

Rules

require-locale

Ensures that for each locale has a translation present in the .xcstrings file.

e.g. ensure that each key has a translation for en and fr

rules:
    require-locale:
        values:
            - en
            - fr
require-localization-state

Ensures that each key has a localization state matching the provided values.

e.g. ensure that each key has a localization state of translated

rules:
    require-localization-state:
        value: translated

To negate this rule use reject-localization-state instead.

require-extraction-state

Ensures that each key has a translation for each extraction state.

e.g. ensure that each key was automatically extracted

rules:
    require-extraction-state:
        value: "automatic"

To negate this rule use reject-extraction-state instead.

Ignoring Keys

To ignore all validation for a particular key, either mark them as "Don't Translate" or include [no-lint] in the key's comment.

To ignore a specific rule, include [no-lint:rule-name] in the key's comment, e.g. [no-lint:require-locale]

Example Output

$ swift run xcstringslint Sources/StringCatalogValidator/Resources/Localizable.xcstrings

`Rejects an entry if its extraction state matches any of the provided values. Known extractions states:  %@`:
  ⚠️ require-localization-state: no translation state found
  ⚠️ require-locale: missing translation for 1 locale: en
`Rejects an entry if its extraction state matchs any of the provided values. Known extractions states:  %@`:
  ⚠️ require-extraction-state: should not have extraction state `stale`
`found state `%@`, expected %@`:
  ⚠️ require-extraction-state: should not have extraction state `stale`
`found state `%@`, expected `%@``:
  ⚠️ require-localization-state: found state `new`, expected `translated`
`found state `%@`, expected one of %@`:
  ⚠️ require-extraction-state: should not have extraction state `stale`
`found state `%@`, expected one of: %@`:
  ⚠️ require-localization-state: found state `new`, expected `translated`

[Warning]: Found 7 total issues in 6 keys

About

Validate your String Catalogs. Release with confidence that your app is properly translated!

Topics

Resources

License

Stars

Watchers

Forks

Languages