Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/pull-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ jobs:
GOOS: linux
GOARCH: 386

i18n-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- run: make i18n-check

docs:
if: needs.files-changed.outputs.docs == 'true' || needs.files-changed.outputs.actions == 'true'
needs: files-changed
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Here's how to run the test suite:
## Translation

All translation work happens on [Crowdin](https://translate.gitea.com).
The only translation that is maintained in this repository is [the English translation](https://github.com/go-gitea/gitea/blob/main/options/locale/locale_en-US.ini).
The only translation that is maintained in this repository is [the English translation](https://github.com/go-gitea/gitea/blob/main/options/locale/locale_en-US.json).
It is synced regularly with Crowdin. \
Other locales on main branch **should not** be updated manually as they will be overwritten with each sync. \
Once a language has reached a **satisfactory percentage** of translated keys (~25%), it will be synced back into this repo and included in the next released version.
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,16 @@ lockfile-check:
exit 1; \
fi

.PHONY: i18n-backport
i18n-backport:
@echo "Backport translations ..."
$(GO) run tools/i18n/backport.go

.PHONY: i18n-check
i18n-check:
@echo "Checking unused translations..."
$(GO) run tools/i18n/check.go

.PHONY: generate-gitignore
generate-gitignore: ## update gitignore files
$(GO) run build/generate-gitignores.go
Expand Down
115 changes: 0 additions & 115 deletions build/backport-locales.go

This file was deleted.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ require (
github.com/caddyserver/certmagic v0.24.0
github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20251013092601-6327009efd21
github.com/chi-middleware/proxy v1.1.1
github.com/deckarep/golang-set/v2 v2.8.0
github.com/dimiro1/reply v0.0.0-20200315094148-d0136a4c9e21
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
github.com/dustin/go-humanize v1.0.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ=
github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dimiro1/reply v0.0.0-20200315094148-d0136a4c9e21 h1:PdsjTl0Cg+ZJgOx/CFV5NNgO1ThTreqdgKYiDCMHJwA=
Expand Down
1 change: 1 addition & 0 deletions models/actions/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (r *ActionRunner) StatusName() string {
}

func (r *ActionRunner) StatusLocaleName(lang translation.Locale) string {
// i18n-check: actions.runners.status.*
return lang.TrString("actions.runners.status." + r.StatusName())
}

Expand Down
1 change: 1 addition & 0 deletions models/actions/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (s Status) String() string {

// LocaleString returns the locale string name of the Status
func (s Status) LocaleString(lang translation.Locale) string {
// i18n-check: actions.status.*
return lang.TrString("actions.status." + s.String())
}

Expand Down
1 change: 1 addition & 0 deletions models/git/commit_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func (status *CommitStatus) APIURL(ctx context.Context) string {

// LocaleString returns the locale string name of the Status
func (status *CommitStatus) LocaleString(lang translation.Locale) string {
// i18n-check: repo.commitstatus.*
return lang.TrString("repo.commitstatus." + status.State.String())
}

Expand Down
2 changes: 2 additions & 0 deletions models/issues/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,13 @@ const (

// LocaleString returns the locale string name of the role
func (r RoleInRepo) LocaleString(lang translation.Locale) string {
// i18n-check: repo.issues.role.*
return lang.TrString("repo.issues.role." + string(r))
}

// LocaleHelper returns the locale tooltip of the role
func (r RoleInRepo) LocaleHelper(lang translation.Locale) string {
// i18n-check: repo.issues.role.*_helper
return lang.TrString("repo.issues.role." + string(r) + "_helper")
}

Expand Down
1 change: 1 addition & 0 deletions modules/auth/password/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func BuildComplexityError(locale translation.Locale) template.HTML {
buffer.WriteString("<ul>")
for _, c := range requiredList {
buffer.WriteString("<li>")
// i18n-check: form.password_*
buffer.WriteString(locale.TrString(c.TrNameOne))
buffer.WriteString("</li>")
}
Expand Down
17 changes: 0 additions & 17 deletions modules/setting/config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,23 +348,6 @@ func deprecatedSettingDB(rootCfg ConfigProvider, oldSection, oldKey string) {
}
}

// NewConfigProviderForLocale loads locale configuration from source and others. "string" if for a local file path, "[]byte" is for INI content
func NewConfigProviderForLocale(source any, others ...any) (ConfigProvider, error) {
iniFile, err := ini.LoadSources(ini.LoadOptions{
IgnoreInlineComment: true,
UnescapeValueCommentSymbols: true,
IgnoreContinuation: true,
}, source, others...)
if err != nil {
return nil, fmt.Errorf("unable to load locale ini: %w", err)
}
iniFile.BlockMode = false
return &iniConfigProvider{
ini: iniFile,
loadedFromEmpty: true,
}, nil
}

func init() {
ini.PrettyFormat = false
}
18 changes: 0 additions & 18 deletions modules/setting/config_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,6 @@ func TestNewConfigProviderFromFile(t *testing.T) {
assert.Equal(t, "[foo]\nk1 = a\n\n[bar]\nk1 = b\n", string(bs))
}

func TestNewConfigProviderForLocale(t *testing.T) {
// load locale from file
localeFile := t.TempDir() + "/locale.ini"
_ = os.WriteFile(localeFile, []byte(`k1=a`), 0o644)
cfg, err := NewConfigProviderForLocale(localeFile)
assert.NoError(t, err)
assert.Equal(t, "a", cfg.Section("").Key("k1").String())

// load locale from bytes
cfg, err = NewConfigProviderForLocale([]byte("k1=foo\nk2=bar"))
assert.NoError(t, err)
assert.Equal(t, "foo", cfg.Section("").Key("k1").String())
cfg, err = NewConfigProviderForLocale([]byte("k1=foo\nk2=bar"), []byte("k2=xxx"))
assert.NoError(t, err)
assert.Equal(t, "foo", cfg.Section("").Key("k1").String())
assert.Equal(t, "xxx", cfg.Section("").Key("k2").String())
}

func TestDisableSaving(t *testing.T) {
testFile := t.TempDir() + "/test.ini"
_ = os.WriteFile(testFile, []byte("k1=a\nk2=b"), 0o644)
Expand Down
Loading
Loading