Browse Source

Handle translations a little better

tags/v1.0.0-rc1
Daniel Oaks 5 years ago
parent
commit
7eef390756
3 changed files with 31 additions and 9 deletions
  1. 21
    0
      DEVELOPING.md
  2. 5
    5
      crowdin.yml
  3. 5
    4
      irc/config.go

+ 21
- 0
DEVELOPING.md View File

@@ -137,3 +137,24 @@ They receive the response with the same label, so they can match the sent comman
137 137
 In order to allow this, in command handlers we don't send responses directly back to the user. Instead, we buffer the responses in an object called a ResponseBuffer. When the command handler returns, the contents of the ResponseBuffer is sent to the user with the appropriate label (and batches, if they're required).
138 138
 
139 139
 Basically, if you're in a command handler and you're sending a response back to the requesting client, use `rb.Add*` instead of `client.Send*`. Doing this makes sure the labeled responses feature above works as expected. The handling around `PRIVMSG`/`NOTICE`/`TAGMSG` is strange, so simply defer to [irctest](https://github.com/DanielOaks/irctest)'s judgement about whether that's correct for the most part.
140
+
141
+
142
+## Updating Translations
143
+
144
+We support translating server strings using [CrowdIn](https://crowdin.com/project/oragono)! To send updated source strings to CrowdIn, you should:
145
+
146
+1. `cd` to the base directory (the one this `DEVELOPING` file is in).
147
+2. Install the `pyyaml` and `docopt` deps using `pip3 install pyyamp docopt`.
148
+3. Run the `updatetranslations.py` script with: `./updatetranslations.py irc languages`
149
+4. Install the [CrowdIn CLI tool](https://support.crowdin.com/cli-tool/).
150
+5. Make sure the CrowdIn API key is correct in `~/.crowdin.yaml`
151
+6. Run `crowdin upload sources`
152
+
153
+We also support grabbing translations directly from CrowdIn. To do this:
154
+
155
+1. `cd` to the base directory (the one this `DEVELOPING` file is in).
156
+2. Install the [CrowdIn CLI tool](https://support.crowdin.com/cli-tool/).
157
+3. Make sure the CrowdIn API key is correct in `~/.crowdin.yaml`
158
+4. Run `crowdin download`
159
+
160
+This will download a bunch of updated files. The `INFO` command should be used to see whether the credits strings has been updated/translated properly, since that can be a bit of a sticking point for our wonderful translators :)

+ 5
- 5
crowdin.yml View File

@@ -23,30 +23,30 @@ files: [
23 23
  },
24 24
  {
25 25
   "source" : "languages/example/irc.lang.json",
26
-  "translation" : "languages/%locale%-irc.lang.yaml",
26
+  "translation" : "languages/%locale%-irc.lang.json",
27 27
   "dest" : "irc.lang.json"
28 28
  },
29 29
  {
30 30
   "source" : "languages/example/help.lang.json",
31
-  "translation" : "languages/%locale%-help.lang.yaml",
31
+  "translation" : "languages/%locale%-help.lang.json",
32 32
   "dest" : "help.lang.json",
33 33
   "update_option" : "update_as_unapproved",
34 34
  },
35 35
  {
36 36
   "source" : "languages/example/chanserv.lang.json",
37
-  "translation" : "languages/%locale%-chanserv.lang.yaml",
37
+  "translation" : "languages/%locale%-chanserv.lang.json",
38 38
   "dest" : "services/chanserv.lang.json",
39 39
   "update_option" : "update_as_unapproved",
40 40
  },
41 41
  {
42 42
   "source" : "languages/example/nickserv.lang.json",
43
-  "translation" : "languages/%locale%-nickserv.lang.yaml",
43
+  "translation" : "languages/%locale%-nickserv.lang.json",
44 44
   "dest" : "services/nickserv.lang.json",
45 45
   "update_option" : "update_as_unapproved",
46 46
  },
47 47
  {
48 48
   "source" : "languages/example/hostserv.lang.json",
49
-  "translation" : "languages/%locale%-hostserv.lang.yaml",
49
+  "translation" : "languages/%locale%-hostserv.lang.json",
50 50
   "dest" : "services/hostserv.lang.json",
51 51
   "update_option" : "update_as_unapproved",
52 52
  },

+ 5
- 4
irc/config.go View File

@@ -697,12 +697,13 @@ func LoadConfig(filename string) (config *Config, err error) {
697 697
 				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")
698 698
 			}
699 699
 
700
-			if langInfo.Code == "" || langInfo.Name == "" || langInfo.Contributors == "" {
701
-				return nil, fmt.Errorf("Code, name or contributors is empty in language file [%s]", name)
700
+			if len(langInfo.Translations) == 0 {
701
+				// skip empty translations
702
+				continue
702 703
 			}
703 704
 
704
-			if len(langInfo.Translations) == 0 {
705
-				return nil, fmt.Errorf("Language [%s / %s] contains no translations", langInfo.Code, langInfo.Name)
705
+			if langInfo.Code == "" || langInfo.Name == "" || langInfo.Contributors == "" {
706
+				return nil, fmt.Errorf("Code, name or contributors is empty in language file [%s]", name)
706 707
 			}
707 708
 
708 709
 			// check for duplicate languages

Loading…
Cancel
Save