Browse Source

Don't load example translation file, make example actually list all translatable strings

tags/v0.11.0-alpha
Daniel Oaks 6 years ago
parent
commit
b2afd55285
3 changed files with 198 additions and 2 deletions
  1. 4
    0
      irc/config.go
  2. 137
    2
      languages/example.lang.yaml
  3. 57
    0
      updatetranslations.py

+ 4
- 0
irc/config.go View File

@@ -501,6 +501,10 @@ func LoadConfig(filename string) (config *Config, err error) {
501 501
 			if !strings.HasSuffix(strings.ToLower(name), ".lang.yaml") {
502 502
 				continue
503 503
 			}
504
+			// don't load our example file in practice
505
+			if strings.ToLower(name) == "example.lang.yaml" {
506
+				continue
507
+			}
504 508
 
505 509
 			data, err = ioutil.ReadFile(filepath.Join(config.Languages.Path, name))
506 510
 			if err != nil {

+ 137
- 2
languages/example.lang.yaml View File

@@ -18,5 +18,140 @@ incomplete: true
18 18
 # stays as-is. the language-update processor uses the next line to designate which part of
19 19
 # the file to ignore and which part to actually process.
20 20
 translations:
21
-  "Welcome to the Internet Relay Network %s": "Welcome braaaah to the IRN broski %s"
22
-  "Language preferences have been set": "You've set your languages man, wicked!"
21
+  "%d IRC Operators online": ""
22
+  "%d channels formed": ""
23
+  "*** Could not find your username": ""
24
+  "*** Found your username": ""
25
+  "*** Got a malformed username, ignoring": ""
26
+  "*** Looking up your username": ""
27
+  "- %s Message of the day - ": ""
28
+  "Account already exists": ""
29
+  "Account created": ""
30
+  "Account name is not valid": ""
31
+  "Account registration is disabled": ""
32
+  "Actual user@host, Actual IP": ""
33
+  "Added K-Line for %s": ""
34
+  "Added temporary (%s) K-Line for %s": ""
35
+  "Authentication successful": ""
36
+  "Ban - %s - added by %s - %s": ""
37
+  "Callback namespace is not supported": ""
38
+  "Can't change modes for other users": ""
39
+  "Can't view modes for other users": ""
40
+  "Cannot join channel (+%s)": ""
41
+  "Cannot resume connection, connection registration has already been completed": ""
42
+  "Cannot resume connection, old and new clients must be logged into the same account": ""
43
+  "Cannot resume connection, old and new clients must have TLS": ""
44
+  "Cannot resume connection, old client not found": ""
45
+  "Cannot resume connection, old nickname contains spaces": ""
46
+  "Cannot send to channel": ""
47
+  "Channel %s successfully registered": ""
48
+  "Channel doesn't have roleplaying mode available": ""
49
+  "Channel list is full": ""
50
+  "Channel name is not valid": ""
51
+  "Channel registration is not enabled": ""
52
+  "Channel renamed: %s": ""
53
+  "Client reconnected": ""
54
+  "Could not apply mode changes: +%s": ""
55
+  "Could not parse IP address or CIDR network": ""
56
+  "Could not register": ""
57
+  "Could not remove ban [%s]": ""
58
+  "Could not set or change nickname: %s": ""
59
+  "Could not successfully save new D-LINE: %s": ""
60
+  "Could not successfully save new K-LINE: %s": ""
61
+  "Credential type is not supported": ""
62
+  "End of /HELPOP": ""
63
+  "End of /WHOIS list": ""
64
+  "End of LIST": ""
65
+  "End of MOTD command": ""
66
+  "End of NAMES list": ""
67
+  "End of WHO list": ""
68
+  "End of WHOWAS": ""
69
+  "End of list": ""
70
+  "Erroneous nickname": ""
71
+  "Fake source must be a valid nickname": ""
72
+  "First param must be a mask or channel": ""
73
+  "HELPOP <argument>\n\nGet an explanation of <argument>, or \"index\" for a list of help topics.": ""
74
+  "Help not found": ""
75
+  "I have %d clients and %d servers": ""
76
+  "Insufficient oper privs": ""
77
+  "Invalid CAP subcommand": ""
78
+  "JOIN 0 is not allowed": ""
79
+  "Language preferences have been set": ""
80
+  "Languages are not supported by this server": ""
81
+  "MOTD File is missing": ""
82
+  "Malformed username": ""
83
+  "Mask isn't valid": ""
84
+  "NickServ is not yet implemented, sorry! To register an account, check /HELPOP REG": ""
85
+  "Nickname is already in use": ""
86
+  "No DLINEs have been set!": ""
87
+  "No command given": ""
88
+  "No masks given": ""
89
+  "No nickname given": ""
90
+  "No such channel": ""
91
+  "No such nick": ""
92
+  "No such server": ""
93
+  "No topic is set": ""
94
+  "Not enough parameters": ""
95
+  "Only channel founders can change registered channels": ""
96
+  "PROXY command is not usable from your address": ""
97
+  "Password incorrect": ""
98
+  "Permission Denied": ""
99
+  "Permission Denied - You're not an IRC operator": ""
100
+  "Proxied IP address is not valid: [%s]": ""
101
+  "Received malformed line": ""
102
+  "Rehashing": ""
103
+  "Remote servers not yet supported": ""
104
+  "Removed D-Line for %s": ""
105
+  "Removed K-Line for %s": ""
106
+  "SASL authentication aborted": ""
107
+  "SASL authentication failed": ""
108
+  "SASL authentication failed, you are not connecting with a certificate": ""
109
+  "SASL authentication failed: Bad account name": ""
110
+  "SASL authentication failed: Invalid auth blob": ""
111
+  "SASL authentication failed: Invalid b64 encoding": ""
112
+  "SASL authentication failed: Passphrase too long": ""
113
+  "SASL authentication failed: authcid and authzid should be the same": ""
114
+  "SASL authentication successful": ""
115
+  "SASL message too long": ""
116
+  "Server notice masks": ""
117
+  "Sorry, I don't know that command": ""
118
+  "Syntax: REGISTER <channel>": ""
119
+  "There are %d users and %d invisible on %d server(s)": ""
120
+  "There was no such nickname": ""
121
+  "They aren't on that channel": ""
122
+  "This ban matches you. To DLINE yourself, you must use the command:  /DLINE MYSELF <arguments>": ""
123
+  "This ban matches you. To KLINE yourself, you must use the command:  /KLINE MYSELF <arguments>": ""
124
+  "This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.": ""
125
+  "This server was created %s": ""
126
+  "Timestamp is not in 2006-01-02T15:04:05.999Z format, ignoring it": ""
127
+  "Unknown command": ""
128
+  "Unknown subcommand": ""
129
+  "User doesn't have roleplaying mode enabled": ""
130
+  "VERIFY is not yet implemented": ""
131
+  "WEBIRC command is not usable from your address or incorrect password given": ""
132
+  "Welcome to the Internet Relay Network %s": ""
133
+  "You are banned from this server (%s)": ""
134
+  "You are no longer marked as being away": ""
135
+  "You are not using a TLS certificate": ""
136
+  "You are now an IRC operator": ""
137
+  "You are now logged in as %s": ""
138
+  "You have been banned from this server (%s)": ""
139
+  "You have been marked as being away": ""
140
+  "You may not reregister": ""
141
+  "You must be an oper on the channel to register it": ""
142
+  "You must be logged in to register a channel": ""
143
+  "You need to register before you can use that command": ""
144
+  "You need to run a command": ""
145
+  "You specified too many languages": ""
146
+  "You're already logged into an account": ""
147
+  "You're already opered-up!": ""
148
+  "You're not a channel operator": ""
149
+  "You're not on that channel": ""
150
+  "Your host is %s, running version %s": ""
151
+  "can speak these languages": ""
152
+  "has client certificate fingerprint %s": ""
153
+  "is a $bBot$b on %s": ""
154
+  "is an unknown mode character to me": ""
155
+  "is logged in as": ""
156
+  "is using a secure connection": ""
157
+  "seconds idle, signon time": ""

+ 57
- 0
updatetranslations.py View File

@@ -0,0 +1,57 @@
1
+#!/usr/bin/env python3
2
+# updatetranslations.py
3
+#
4
+# tl;dr this script updates our translation file with the newest, coolest strings we've added!
5
+# it manually searches the source code, extracts strings and then updates the language files.
6
+
7
+# Written in 2018 by Daniel Oaks <daniel@danieloaks.net>
8
+#
9
+# To the extent possible under law, the author(s) have dedicated all copyright
10
+# and related and neighboring rights to this software to the public domain
11
+# worldwide. This software is distributed without any warranty.
12
+#
13
+# You should have received a copy of the CC0 Public Domain Dedication along
14
+# with this software. If not, see
15
+# <http://creativecommons.org/publicdomain/zero/1.0/>.
16
+
17
+"""updatetranslations.py
18
+
19
+Usage:
20
+    updatetranslations.py run <irc-dir> <languages-dir>
21
+    updatetranslations.py --version
22
+    updatetranslations.py (-h | --help)
23
+
24
+Options:
25
+    <irc-dir>        Oragono's irc subdirectory where the Go code is kept.
26
+    <languages-dir>  Languages directory."""
27
+import os
28
+import re
29
+
30
+from docopt import docopt
31
+import yaml
32
+
33
+if __name__ == '__main__':
34
+    arguments = docopt(__doc__, version="0.1.0")
35
+
36
+    if arguments['run']:
37
+        lang_strings = []
38
+
39
+        for subdir, dirs, files in os.walk(arguments['<irc-dir>']):
40
+            for fname in files:
41
+                filepath = subdir + os.sep + fname
42
+                if filepath.endswith('.go'):
43
+                    content = open(filepath, 'r').read()
44
+
45
+                    matches = re.findall(r'\.t\("((?:[^"]|\\")+)"\)', content)
46
+                    for match in matches:
47
+                        if match not in lang_strings:
48
+                            lang_strings.append(match)
49
+
50
+                    matches = re.findall(r'\.t\(\`([^\`]+)\`\)', content)
51
+                    for match in matches:
52
+                        match = match.replace("\n", "\\n").replace("\"", "\\\"")
53
+                        if match not in lang_strings:
54
+                            lang_strings.append(match)
55
+
56
+        for match in sorted(lang_strings):
57
+            print('  "' + match + '": ""')

Loading…
Cancel
Save