mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 16:04:38 +01:00
initial multi-language concept
This commit is contained in:
6
patch-schema/language.sql
Normal file
6
patch-schema/language.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.users
|
||||||
|
ADD COLUMN IF NOT EXISTS language text NOT NULL DEFAULT 'en';
|
||||||
|
|
||||||
|
END;
|
||||||
@@ -141,6 +141,8 @@ func handleMsgSysLogin(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.charID = pkt.CharID0
|
s.charID = pkt.CharID0
|
||||||
s.token = pkt.LoginTokenString
|
s.token = pkt.LoginTokenString
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
|
|
||||||
|
s.dict = getLangStrings(s)
|
||||||
updateRights(s)
|
updateRights(s)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
bf.WriteUint32(uint32(Time_Current_Adjusted().Unix())) // Unix timestamp
|
bf.WriteUint32(uint32(Time_Current_Adjusted().Unix())) // Unix timestamp
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ func handleMsgMhfGetCafeDuration(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
bf.WriteUint32(cafeTime) // Total cafe time
|
bf.WriteUint32(cafeTime) // Total cafe time
|
||||||
bf.WriteUint16(0)
|
bf.WriteUint16(0)
|
||||||
ps.Uint16(bf, fmt.Sprintf("Resets on %s %d", cafeReset.Month().String(), cafeReset.Day()), true)
|
ps.Uint16(bf, fmt.Sprintf(s.dict["cafeReset"], int(cafeReset.Month()), cafeReset.Day()), true)
|
||||||
|
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
21
server/channelserver/handlers_lang.go
Normal file
21
server/channelserver/handlers_lang.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package channelserver
|
||||||
|
|
||||||
|
import "go.uber.org/zap"
|
||||||
|
|
||||||
|
func getLangStrings(s *Session) map[string]string {
|
||||||
|
var lang string
|
||||||
|
strings := make(map[string]string)
|
||||||
|
err := s.server.db.QueryRow(`SELECT language FROM users, characters WHERE characters.id = $1 AND users.id = characters.user_id`, s.charID).Scan(&lang)
|
||||||
|
if err != nil {
|
||||||
|
s.logger.Warn("No language set for user", zap.Uint32("CID", s.charID))
|
||||||
|
}
|
||||||
|
switch lang {
|
||||||
|
case "jp":
|
||||||
|
strings["language"] = "日本語"
|
||||||
|
strings["cafeReset"] = "%d/%dにリセット"
|
||||||
|
default:
|
||||||
|
strings["language"] = "English"
|
||||||
|
strings["cafeReset"] = "Resets on %d/%d"
|
||||||
|
}
|
||||||
|
return strings
|
||||||
|
}
|
||||||
@@ -47,6 +47,8 @@ type Session struct {
|
|||||||
kqf []byte
|
kqf []byte
|
||||||
kqfOverride bool
|
kqfOverride bool
|
||||||
|
|
||||||
|
dict map[string]string
|
||||||
|
|
||||||
semaphore *Semaphore // Required for the stateful MsgSysUnreserveStage packet.
|
semaphore *Semaphore // Required for the stateful MsgSysUnreserveStage packet.
|
||||||
|
|
||||||
// A stack containing the stage movement history (push on enter/move, pop on back)
|
// A stack containing the stage movement history (push on enter/move, pop on back)
|
||||||
|
|||||||
Reference in New Issue
Block a user