diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b1fa4a3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,50 @@ +# GitHub Actions workflow to lint the locale files. +name: "Lint" +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + merge_group: + +concurrency: + group: "${{ github.workflow }}-${{ github.event.number || github.ref }}" + cancel-in-progress: "${{ github.event.action != 'merge_group' }}" + +permissions: + contents: read + +jobs: + lint: + name: "Lint" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout repository" + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 + with: + fetch-depth: 0 + submodules: true + + - name: "Setup Go stable" + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 + with: + go-version: "stable" + cache: true + check-latest: true + + - name: "Download dependencies" + run: go mod download + + - name: "Verify dependencies" + run: go mod verify + + - name: "Build" + run: go build -v ./... + + - name: "Test" + run: go test -race -v ./... + + - name: "Lint" + run: | + go build -trimpath ./cmd/lang-lint + ./lang-lint diff --git a/cmd/lang-lint/main.go b/cmd/lang-lint/main.go new file mode 100644 index 0000000..1812664 --- /dev/null +++ b/cmd/lang-lint/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "hypera.dev/axolotl-lang/v2" +) + +func main() { + if err := lang.LoadLocales(); err != nil { + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + + fmt.Println("Locales loaded successfully", lang.Bundle().LanguageTags()) +} diff --git a/lang.go b/lang.go index 543be48..34f69d4 100644 --- a/lang.go +++ b/lang.go @@ -41,6 +41,10 @@ func LoadLocales() error { return nil } +func Bundle() *i18n.Bundle { + return bundle +} + func GetLocalizer(locale discordgo.Locale) (*Localizer, bool) { if l, ok := locales[locale]; ok { return l, true