🌐 Use plural extention in locale source files
This commit is contained in:
parent
162b07396a
commit
891b6cf7a6
|
@ -49,20 +49,23 @@ var messageKeyToIndex = map[string]int{
|
||||||
|
|
||||||
var enIndex = []uint32{ // 7 elements
|
var enIndex = []uint32{ // 7 elements
|
||||||
0x00000000, 0x00000008, 0x00000013, 0x0000002a,
|
0x00000000, 0x00000008, 0x00000013, 0x0000002a,
|
||||||
0x00000046, 0x00000055, 0x00000067,
|
0x00000046, 0x00000055, 0x00000092,
|
||||||
} // Size: 52 bytes
|
} // Size: 52 bytes
|
||||||
|
|
||||||
const enData string = "" + // Size: 103 bytes
|
const enData string = "" + // Size: 146 bytes
|
||||||
"\x02version\x02%[1]s logo\x02Dead simple WebSub hub\x02How to publish an" +
|
"\x02version\x02%[1]s logo\x02Dead simple WebSub hub\x02How to publish an" +
|
||||||
"d consume?\x02What the spec?\x02%[1]d subscribers"
|
"d consume?\x02What the spec?\x14\x01\x81\x01\x00=\x00\x0f\x02no subscrib" +
|
||||||
|
"ers=\x01\x0f\x02one subscriber\x00\x12\x02%[1]d subscribers"
|
||||||
|
|
||||||
var ruIndex = []uint32{ // 7 elements
|
var ruIndex = []uint32{ // 7 elements
|
||||||
0x00000000, 0x0000000d, 0x00000022, 0x00000045,
|
0x00000000, 0x0000000d, 0x00000022, 0x00000045,
|
||||||
0x0000007a, 0x00000090, 0x000000ad,
|
0x0000007a, 0x00000090, 0x00000111,
|
||||||
} // Size: 52 bytes
|
} // Size: 52 bytes
|
||||||
|
|
||||||
const ruData string = "" + // Size: 173 bytes
|
const ruData string = "" + // Size: 273 bytes
|
||||||
"\x02версия\x02логотип %[1]s\x02Простейший хаб WebSub\x02Как публиковать " +
|
"\x02версия\x02логотип %[1]s\x02Простейший хаб WebSub\x02Как публиковать " +
|
||||||
"и принимать?\x02В чём спека?\x02%[1]d подписчиков"
|
"и принимать?\x02В чём спека?\x14\x01\x81\x01\x00=\x00\x1e\x02без подпис" +
|
||||||
|
"чиков=\x01\x1c\x02один подписчик\x04\x1b\x02%[1]d подписчика\x00\x1d" +
|
||||||
|
"\x02%[1]d подписчиков"
|
||||||
|
|
||||||
// Total table size 380 bytes (0KiB); checksum: 7D8C2E8B
|
// Total table size 523 bytes (0KiB); checksum: 6AB3BB61
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
{
|
||||||
|
"language": "en",
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"id": "version",
|
||||||
|
"message": "version",
|
||||||
|
"translation": "version",
|
||||||
|
"translatorComment": "Copied from source.",
|
||||||
|
"fuzzy": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{Name} logo",
|
||||||
|
"message": "{Name} logo",
|
||||||
|
"translation": "{Name} logo",
|
||||||
|
"translatorComment": "Copied from source.",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Name",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "p.name"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fuzzy": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Dead simple WebSub hub",
|
||||||
|
"message": "Dead simple WebSub hub",
|
||||||
|
"translation": "Dead simple WebSub hub",
|
||||||
|
"translatorComment": "Copied from source.",
|
||||||
|
"fuzzy": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "How to publish and consume?",
|
||||||
|
"message": "How to publish and consume?",
|
||||||
|
"translation": "How to publish and consume?",
|
||||||
|
"translatorComment": "Copied from source.",
|
||||||
|
"fuzzy": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "What the spec?",
|
||||||
|
"message": "What the spec?",
|
||||||
|
"translation": "What the spec?",
|
||||||
|
"translatorComment": "Copied from source.",
|
||||||
|
"fuzzy": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{Subscribers} subscribers",
|
||||||
|
"message": "{Subscribers} subscribers",
|
||||||
|
"translation": {
|
||||||
|
"select": {
|
||||||
|
"feature": "plural",
|
||||||
|
"arg": "Subscribers",
|
||||||
|
"cases": {
|
||||||
|
"=0": {
|
||||||
|
"msg": "no subscribers"
|
||||||
|
},
|
||||||
|
"=1": {
|
||||||
|
"msg": "one subscriber"
|
||||||
|
},
|
||||||
|
"other": {
|
||||||
|
"msg": "{Subscribers} subscribers"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"translatorComment": "Added plural feature support.",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Subscribers",
|
||||||
|
"string": "%[1]d",
|
||||||
|
"type": "int",
|
||||||
|
"underlyingType": "int",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "p.Subscribers"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fuzzy": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -49,8 +49,24 @@
|
||||||
{
|
{
|
||||||
"id": "{Subscribers} subscribers",
|
"id": "{Subscribers} subscribers",
|
||||||
"message": "{Subscribers} subscribers",
|
"message": "{Subscribers} subscribers",
|
||||||
"translation": "{Subscribers} subscribers",
|
"translation": {
|
||||||
"translatorComment": "Copied from source.",
|
"select": {
|
||||||
|
"feature": "plural",
|
||||||
|
"arg": "Subscribers",
|
||||||
|
"cases": {
|
||||||
|
"=0": {
|
||||||
|
"msg": "no subscribers"
|
||||||
|
},
|
||||||
|
"=1": {
|
||||||
|
"msg": "one subscriber"
|
||||||
|
},
|
||||||
|
"other": {
|
||||||
|
"msg": "{Subscribers} subscribers"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"translatorComment": "Added plural feature support.",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Subscribers",
|
"id": "Subscribers",
|
||||||
|
|
|
@ -39,7 +39,26 @@
|
||||||
{
|
{
|
||||||
"id": "{Subscribers} subscribers",
|
"id": "{Subscribers} subscribers",
|
||||||
"message": "{Subscribers} subscribers",
|
"message": "{Subscribers} subscribers",
|
||||||
"translation": "{Subscribers} подписчиков",
|
"translation": {
|
||||||
|
"select": {
|
||||||
|
"feature": "plural",
|
||||||
|
"arg": "Subscribers",
|
||||||
|
"cases": {
|
||||||
|
"=0": {
|
||||||
|
"msg": "без подписчиков"
|
||||||
|
},
|
||||||
|
"=1": {
|
||||||
|
"msg": "один подписчик"
|
||||||
|
},
|
||||||
|
"few": {
|
||||||
|
"msg": "{Subscribers} подписчика"
|
||||||
|
},
|
||||||
|
"other": {
|
||||||
|
"msg": "{Subscribers} подписчиков"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Subscribers",
|
"id": "Subscribers",
|
||||||
|
|
|
@ -39,7 +39,26 @@
|
||||||
{
|
{
|
||||||
"id": "{Subscribers} subscribers",
|
"id": "{Subscribers} subscribers",
|
||||||
"message": "{Subscribers} subscribers",
|
"message": "{Subscribers} subscribers",
|
||||||
"translation": "{Subscribers} подписчиков",
|
"translation": {
|
||||||
|
"select": {
|
||||||
|
"feature": "plural",
|
||||||
|
"arg": "Subscribers",
|
||||||
|
"cases": {
|
||||||
|
"=0": {
|
||||||
|
"msg": "без подписчиков"
|
||||||
|
},
|
||||||
|
"=1": {
|
||||||
|
"msg": "один подписчик"
|
||||||
|
},
|
||||||
|
"few": {
|
||||||
|
"msg": "{Subscribers} подписчика"
|
||||||
|
},
|
||||||
|
"other": {
|
||||||
|
"msg": "{Subscribers} подписчиков"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Subscribers",
|
"id": "Subscribers",
|
||||||
|
|
18
main.go
18
main.go
|
@ -16,7 +16,6 @@ import (
|
||||||
|
|
||||||
"github.com/caarlos0/env/v10"
|
"github.com/caarlos0/env/v10"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"golang.org/x/text/feature/plural"
|
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
"golang.org/x/text/message"
|
"golang.org/x/text/message"
|
||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
|
@ -37,23 +36,6 @@ var logger = log.New(os.Stdout, "hub\t", log.LstdFlags)
|
||||||
//go:embed web/static/*
|
//go:embed web/static/*
|
||||||
var static embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
func init() {
|
|
||||||
message.Set(language.English, "%d subscribers",
|
|
||||||
plural.Selectf(1, "%d",
|
|
||||||
"one", "%d subscriber",
|
|
||||||
"other", "%d subscribers",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
message.Set(language.Russian, "%d subscribers",
|
|
||||||
plural.Selectf(1, "%d",
|
|
||||||
"one", "%d подписчик",
|
|
||||||
"few", "%d подписчика",
|
|
||||||
"many", "%d подписчиков",
|
|
||||||
"other", "%d подписчика",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue