-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add locale support ford deprecated messages
- Loading branch information
1 parent
ca2c7d5
commit 654a8a9
Showing
4 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package locale | ||
|
||
var ( | ||
localeRegistry = make(map[string]*Locale) | ||
current = defaultLocal | ||
) | ||
|
||
type Locale struct { | ||
// deprecated messages for graphical clients | ||
DeprecatedMessage string | ||
DeprecatedMessageNoLink string | ||
} | ||
|
||
var defaultLocal = &Locale{ | ||
DeprecatedMessage: "%s is deprecated in sing-box %s and will be removed in sing-box %s please checkout documentation for migration.", | ||
DeprecatedMessageNoLink: "%s is deprecated in sing-box %s and will be removed in sing-box %s.", | ||
} | ||
|
||
func Current() *Locale { | ||
return current | ||
} | ||
|
||
func Set(localeId string) bool { | ||
locale, loaded := localeRegistry[localeId] | ||
if !loaded { | ||
return false | ||
} | ||
current = locale | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package locale | ||
|
||
var warningMessageForEndUsers = "\n\n如果您不明白此消息意味着什么:您的配置文件已过时,且将很快不可用。请联系您的配置提供者以更新配置。" | ||
|
||
func init() { | ||
localeRegistry["zh_CN"] = &Locale{ | ||
DeprecatedMessage: "%%s 已在 sing-box %s 中被弃用,且将在 sing-box %s 中被移除,请参阅迁移指南。" + warningMessageForEndUsers, | ||
DeprecatedMessageNoLink: "%%s 已在 sing-box %s 中被弃用,且将在 sing-box %s 中被移除。" + warningMessageForEndUsers, | ||
} | ||
} |