Skip to content

Commit

Permalink
fix: change fail
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored and kumfo committed Sep 5, 2024
1 parent 26afc09 commit 1d33c88
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7239,9 +7239,9 @@ const docTemplate = `{
"parameters": [
{
"type": "string",
"description": "Accept-Language",
"name": "Accept-Language",
"in": "header",
"description": "installation language",
"name": "lang",
"in": "query",
"required": true
}
],
Expand Down
6 changes: 3 additions & 3 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7213,9 +7213,9 @@
"parameters": [
{
"type": "string",
"description": "Accept-Language",
"name": "Accept-Language",
"in": "header",
"description": "installation language",
"name": "lang",
"in": "query",
"required": true
}
],
Expand Down
6 changes: 3 additions & 3 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7243,9 +7243,9 @@ paths:
get:
description: get installation language config mapping
parameters:
- description: Accept-Language
in: header
name: Accept-Language
- description: installation language
in: query
name: lang
required: true
type: string
produces:
Expand Down
6 changes: 4 additions & 2 deletions internal/install/install_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"github.com/segmentfault/pacman/errors"
"github.com/segmentfault/pacman/i18n"
"github.com/segmentfault/pacman/log"
)

Expand All @@ -56,7 +57,7 @@ func LangOptions(ctx *gin.Context) {
// @Summary get installation language config mapping
// @Description get installation language config mapping
// @Tags Lang
// @Param Accept-Language header string true "Accept-Language"
// @Param lang query string true "installation language"
// @Produce json
// @Success 200 {object} handler.RespBody{}
// @Router /installation/language/config [get]
Expand All @@ -66,7 +67,8 @@ func GetLangMapping(ctx *gin.Context) {
handler.HandleResponse(ctx, err, nil)
return
}
trData, _ := t.Dump(handler.GetLang(ctx))
lang := ctx.Query("lang")
trData, _ := t.Dump(i18n.Language(lang))
var resp map[string]any
_ = json.Unmarshal(trData, &resp)
handler.HandleResponse(ctx, nil, resp)
Expand Down
4 changes: 2 additions & 2 deletions ui/src/services/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export const getInstallLangOptions = () => {
return request.get('/installation/language/options');
};

export const getInstallLanguageConfig = () => {
return request.get('/installation/language/config');
export const getInstallLanguageConfig = (lang: string) => {
return request.get(`/installation/language/config?lang=${lang}`);
};
6 changes: 2 additions & 4 deletions ui/src/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const loadLanguageOptions = async (forAdmin = false) => {

const pullLanguageConf = (res) => {
if (window.location.pathname === '/install') {
return getInstallLanguageConfig().then((langConf) => {
return getInstallLanguageConfig(res.lng).then((langConf) => {
if (langConf && langConf.ui) {
res.resources = langConf.ui;
Storage.set(LANG_RESOURCE_STORAGE_KEY, res);
Expand Down Expand Up @@ -162,9 +162,7 @@ export const setupAppTheme = () => {
};

export const setupInstallLanguage = async (lang) => {
if (!i18next.getDataByLanguage(lang)?.translation) {
await addI18nResource(lang);
}
await addI18nResource(lang);
localeDayjs(lang);
i18next.changeLanguage(lang);
};

0 comments on commit 1d33c88

Please sign in to comment.