Browse Source

Update translation framework

tags/v0.11.0-alpha
Daniel Oaks 6 years ago
parent
commit
1a5ff05493
7 changed files with 24 additions and 23 deletions
  1. 3
    3
      irc/config.go
  2. 2
    2
      irc/dline.go
  3. 1
    1
      irc/kline.go
  4. 3
    3
      irc/languages.go
  5. 3
    3
      irc/server.go
  6. 7
    6
      languages/example-irc.lang.json
  7. 5
    5
      languages/example.lang.yaml

+ 3
- 3
irc/config.go View File

@@ -149,7 +149,7 @@ type StackImpactConfig struct {
149 149
 type LangData struct {
150 150
 	Name         string
151 151
 	Code         string
152
-	Maintainers  string
152
+	Contributors string
153 153
 	Incomplete   bool
154 154
 	Translations map[string]string
155 155
 }
@@ -571,8 +571,8 @@ func LoadConfig(filename string) (config *Config, err error) {
571 571
 				return nil, fmt.Errorf("Cannot have language file with code 'en' (this is the default language using strings inside the server code). If you're making an English variant, name it with a more specific code")
572 572
 			}
573 573
 
574
-			if langInfo.Code == "" || langInfo.Name == "" || langInfo.Maintainers == "" {
575
-				return nil, fmt.Errorf("Code, name or maintainers is empty in language file [%s]", name)
574
+			if langInfo.Code == "" || langInfo.Name == "" || langInfo.Contributors == "" {
575
+				return nil, fmt.Errorf("Code, name or contributors is empty in language file [%s]", name)
576 576
 			}
577 577
 
578 578
 			if len(langInfo.Translations) == 0 {

+ 2
- 2
irc/dline.go View File

@@ -236,7 +236,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
236 236
 		}
237 237
 
238 238
 		for key, info := range bans {
239
-			client.Notice(fmt.Sprintf(client.t("Ban - %s - added by %s - %s"), key, info.OperName, info.BanMessage("%s")))
239
+			client.Notice(fmt.Sprintf(client.t("Ban - %[1]s - added by %[2]s - %[3]s"), key, info.OperName, info.BanMessage("%s")))
240 240
 		}
241 241
 
242 242
 		return false
@@ -372,7 +372,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
372 372
 
373 373
 	var snoDescription string
374 374
 	if durationIsUsed {
375
-		client.Notice(fmt.Sprintf(client.t("Added temporary (%s) D-Line for %s"), duration.String(), hostString))
375
+		client.Notice(fmt.Sprintf(client.t("Added temporary (%[1]s) D-Line for %[2]s"), duration.String(), hostString))
376 376
 		snoDescription = fmt.Sprintf(ircfmt.Unescape("%s [%s]$r added temporary (%s) D-Line for %s"), client.nick, operName, duration.String(), hostString)
377 377
 	} else {
378 378
 		client.Notice(fmt.Sprintf(client.t("Added D-Line for %s"), hostString))

+ 1
- 1
irc/kline.go View File

@@ -269,7 +269,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
269 269
 
270 270
 	var snoDescription string
271 271
 	if durationIsUsed {
272
-		client.Notice(fmt.Sprintf(client.t("Added temporary (%s) K-Line for %s"), duration.String(), mask))
272
+		client.Notice(fmt.Sprintf(client.t("Added temporary (%[1]s) K-Line for %[2]s"), duration.String(), mask))
273 273
 		snoDescription = fmt.Sprintf(ircfmt.Unescape("%s [%s]$r added temporary (%s) K-Line for %s"), client.nick, operName, duration.String(), mask)
274 274
 	} else {
275 275
 		client.Notice(fmt.Sprintf(client.t("Added K-Line for %s"), mask))

+ 3
- 3
irc/languages.go View File

@@ -26,9 +26,9 @@ func NewLanguageManager(defaultLang string, languageData map[string]LangData) *L
26 26
 
27 27
 	// make fake "en" info
28 28
 	lm.Info["en"] = LangData{
29
-		Code:        "en",
30
-		Name:        "English",
31
-		Maintainers: "Oragono contributors and the IRC community",
29
+		Code:         "en",
30
+		Name:         "English",
31
+		Contributors: "Oragono contributors and the IRC community",
32 32
 	}
33 33
 
34 34
 	// load language data

+ 3
- 3
irc/server.go View File

@@ -428,7 +428,7 @@ func (server *Server) tryRegister(c *Client) {
428 428
 	//NOTE(dan): we specifically use the NICK here instead of the nickmask
429 429
 	// see http://modern.ircdocs.horse/#rplwelcome-001 for details on why we avoid using the nickmask
430 430
 	c.Send(nil, server.name, RPL_WELCOME, c.nick, fmt.Sprintf(c.t("Welcome to the Internet Relay Network %s"), c.nick))
431
-	c.Send(nil, server.name, RPL_YOURHOST, c.nick, fmt.Sprintf(c.t("Your host is %s, running version %s"), server.name, Ver))
431
+	c.Send(nil, server.name, RPL_YOURHOST, c.nick, fmt.Sprintf(c.t("Your host is %[1]s, running version %[2]s"), server.name, Ver))
432 432
 	c.Send(nil, server.name, RPL_CREATED, c.nick, fmt.Sprintf(c.t("This server was created %s"), server.ctime.Format(time.RFC1123)))
433 433
 	//TODO(dan): Look at adding last optional [<channel modes with a parameter>] parameter
434 434
 	c.Send(nil, server.name, RPL_MYINFO, c.nick, server.name, Ver, supportedUserModesString, supportedChannelModesString)
@@ -2094,10 +2094,10 @@ func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
2094 2094
 			opercount++
2095 2095
 		}
2096 2096
 	}
2097
-	client.Send(nil, server.name, RPL_LUSERCLIENT, client.nick, fmt.Sprintf(client.t("There are %d users and %d invisible on %d server(s)"), totalcount, invisiblecount, 1))
2097
+	client.Send(nil, server.name, RPL_LUSERCLIENT, client.nick, fmt.Sprintf(client.t("There are %[1]d users and %[2]d invisible on %[3]d server(s)"), totalcount, invisiblecount, 1))
2098 2098
 	client.Send(nil, server.name, RPL_LUSEROP, client.nick, fmt.Sprintf(client.t("%d IRC Operators online"), opercount))
2099 2099
 	client.Send(nil, server.name, RPL_LUSERCHANNELS, client.nick, fmt.Sprintf(client.t("%d channels formed"), server.channels.Len()))
2100
-	client.Send(nil, server.name, RPL_LUSERME, client.nick, fmt.Sprintf(client.t("I have %d clients and %d servers"), totalcount, 1))
2100
+	client.Send(nil, server.name, RPL_LUSERME, client.nick, fmt.Sprintf(client.t("I have %[1]d clients and %[2]d servers"), totalcount, 1))
2101 2101
 	return false
2102 2102
 }
2103 2103
 

+ 7
- 6
languages/example-irc.lang.json View File

@@ -13,9 +13,10 @@
13 13
   "Actual user@host, Actual IP": "Actual user@host, Actual IP",
14 14
   "Added D-Line for %s": "Added D-Line for %s",
15 15
   "Added K-Line for %s": "Added K-Line for %s",
16
-  "Added temporary (%s) D-Line for %s": "Added temporary (%s) D-Line for %s",
17
-  "Added temporary (%s) K-Line for %s": "Added temporary (%s) K-Line for %s",
16
+  "Added temporary (%[1]s) D-Line for %[2]s": "Added temporary (%[1]s) D-Line for %[2]s",
17
+  "Added temporary (%[1]s) K-Line for %[2]s": "Added temporary (%[1]s) K-Line for %[2]s",
18 18
   "Authentication successful": "Authentication successful",
19
+  "Ban - %[1]s - added by %[2]s - %[3]s": "Ban - %[1]s - added by %[2]s - %[3]s",
19 20
   "Ban - %s - added by %s - %s": "Ban - %s - added by %s - %s",
20 21
   "Callback namespace is not supported": "Callback namespace is not supported",
21 22
   "Can't change modes for other users": "Can't change modes for other users",
@@ -57,7 +58,7 @@
57 58
   "First param must be a mask or channel": "First param must be a mask or channel",
58 59
   "HELPOP <argument>\n\nGet an explanation of <argument>, or \"index\" for a list of help topics.": "HELPOP <argument>\n\nGet an explanation of <argument>, or \"index\" for a list of help topics.",
59 60
   "Help not found": "Help not found",
60
-  "I have %d clients and %d servers": "I have %d clients and %d servers",
61
+  "I have %[1]d clients and %[2]d servers": "I have %[1]d clients and %[2]d servers",
61 62
   "Insufficient oper privs": "Insufficient oper privs",
62 63
   "Invalid CAP subcommand": "Invalid CAP subcommand",
63 64
   "JOIN 0 is not allowed": "JOIN 0 is not allowed",
@@ -103,7 +104,7 @@
103 104
   "Sorry, I don't know that command": "Sorry, I don't know that command",
104 105
   "Syntax: REGISTER <channel>": "Syntax: REGISTER <channel>",
105 106
   "Thanks to Jeremy Latt for founding Ergonomadic, the project this is based on <3": "Thanks to Jeremy Latt for founding Ergonomadic, the project this is based on <3",
106
-  "There are %d users and %d invisible on %d server(s)": "There are %d users and %d invisible on %d server(s)",
107
+  "There are %[1]d users and %[2]d invisible on %[3]d server(s)": "There are %[1]d users and %[2]d invisible on %[3]d server(s)",
107 108
   "There was no such nickname": "There was no such nickname",
108 109
   "They aren't on that channel": "They aren't on that channel",
109 110
   "This ban matches you. To DLINE yourself, you must use the command:  /DLINE MYSELF <arguments>": "This ban matches you. To DLINE yourself, you must use the command:  /DLINE MYSELF <arguments>",
@@ -134,7 +135,7 @@
134 135
   "You're already opered-up!": "You're already opered-up!",
135 136
   "You're not a channel operator": "You're not a channel operator",
136 137
   "You're not on that channel": "You're not on that channel",
137
-  "Your host is %s, running version %s": "Your host is %s, running version %s",
138
+  "Your host is %[1]s, running version %[2]s": "Your host is %[1]s, running version %[2]s",
138 139
   "can speak these languages": "can speak these languages",
139 140
   "has client certificate fingerprint %s": "has client certificate fingerprint %s",
140 141
   "is a $bBot$b on %s": "is a $bBot$b on %s",
@@ -142,4 +143,4 @@
142 143
   "is logged in as": "is logged in as",
143 144
   "is using a secure connection": "is using a secure connection",
144 145
   "seconds idle, signon time": "seconds idle, signon time"
145
-}
146
+}

+ 5
- 5
languages/example.lang.yaml View File

@@ -1,4 +1,4 @@
1
-# language info file for our example language
1
+# translation info file for our example language
2 2
 #
3 3
 # languages are made up of a few different files:
4 4
 #    <locale>.lang.yaml       - general info about the translation
@@ -8,13 +8,13 @@
8 8
 # we split up translations in this way so that they can be displayed more nicely on CrowdIn
9 9
 
10 10
 # name - this is the 'nice' or 'full' name of the language
11
-name: "Example"
11
+name: "English"
12 12
 
13 13
 # code - this is what the language will be referred to in our list of languages
14
-code: "example"
14
+code: "en"
15 15
 
16
-# maintainers - these are the maintainer details given
17
-maintainers: "Daniel Oaks <daniel@danieloaks.net>"
16
+# contributors - people who have contributed to this translation
17
+contributors: "Example Person <example@example.com>"
18 18
 
19 19
 # incomplete - whether to mark this language as incomplete
20 20
 incomplete: true

Loading…
Cancel
Save