feat: refactor backend i18n (#1373)

* fix: handle the dataSourceName when DB changes

* reduce duplication of code

* feat: refactor translation error message

* feat: use json intsead of ini file

* remove useless translation

* fix translate problems

* remove useless addition

* fix pr problems

* fix pr problems

* fix split problem

* use gofumpt to fmt code

* use crowdin to execute backend translation

* fix pr problems

* refactor: change translation file structure same as frontend

* delete useless output

* update go.mod
This commit is contained in:
Mr Forest
2022-12-07 13:13:23 +08:00
committed by GitHub
parent 96566a626b
commit 1bb3d2dea9
49 changed files with 1604 additions and 1301 deletions

View File

@ -47,7 +47,7 @@ func (c *ApiController) Unlink() {
if user.Id != unlinkedUser.Id && !user.IsGlobalAdmin {
// if the user is not the same as the one we are unlinking, we need to make sure the user is the global admin.
c.ResponseError(c.T("AuthErr.CanNotUnlinkUsers"))
c.ResponseError(c.T("link:You are not the global admin, you can't unlink other users"))
return
}
@ -55,23 +55,23 @@ func (c *ApiController) Unlink() {
// if the user is unlinking themselves, should check the provider can be unlinked, if not, we should return an error.
application := object.GetApplicationByUser(user)
if application == nil {
c.ResponseError(c.T("AuthErr.CanNotLinkMySelf"))
c.ResponseError(c.T("link:You can't unlink yourself, you are not a member of any application"))
return
}
if len(application.Providers) == 0 {
c.ResponseError(c.T("ApplicationErr.HasNoProviders"))
c.ResponseError(c.T("link:This application has no providers"))
return
}
provider := application.GetProviderItemByType(providerType)
if provider == nil {
c.ResponseError(c.T("ApplicationErr.HasNoProvidersOfType") + providerType)
c.ResponseError(c.T("link:This application has no providers of type") + providerType)
return
}
if !provider.CanUnlink {
c.ResponseError(c.T("ProviderErr.CanNotBeUnlinked"))
c.ResponseError(c.T("link:This provider can't be unlinked"))
return
}
@ -84,7 +84,7 @@ func (c *ApiController) Unlink() {
value := object.GetUserField(&unlinkedUser, providerType)
if value == "" {
c.ResponseError(c.T("ProviderErr.LinkFirstErr"), value)
c.ResponseError(c.T("link:Please link first"), value)
return
}