Procházet zdrojové kódy

Be less strict with our language file loading, and handle multiple credits better

tags/v1.0.0-rc1
Daniel Oaks před 5 roky
rodič
revize
46f8ef9ed3
2 změnil soubory, kde provedl 24 přidání a 28 odebrání
  1. 23
    27
      irc/config.go
  2. 1
    1
      irc/handlers.go

+ 23
- 27
irc/config.go Zobrazit soubor

@@ -627,7 +627,7 @@ func LoadConfig(filename string) (config *Config, err error) {
627 627
 				continue
628 628
 			}
629 629
 
630
-			// only load core .lang.yaml files, and ignore help/irc files
630
+			// only load core .lang.yaml file, and ignore help/irc files
631 631
 			name := f.Name()
632 632
 			lowerName := strings.ToLower(name)
633 633
 			if !strings.HasSuffix(lowerName, ".lang.yaml") {
@@ -658,42 +658,38 @@ func LoadConfig(filename string) (config *Config, err error) {
658 658
 			ircName := strings.TrimSuffix(name, ".lang.yaml") + "-irc.lang.json"
659 659
 
660 660
 			data, err = ioutil.ReadFile(filepath.Join(config.Languages.Path, ircName))
661
-			if err != nil {
662
-				return nil, fmt.Errorf("Could not load language's irc file [%s]: %s", ircName, err.Error())
663
-			}
664
-
665
-			err = json.Unmarshal(data, &tlList)
666
-			if err != nil {
667
-				return nil, fmt.Errorf("Could not parse language's irc file [%s]: %s", ircName, err.Error())
668
-			}
661
+			if err == nil {
662
+				err = json.Unmarshal(data, &tlList)
663
+				if err != nil {
664
+					return nil, fmt.Errorf("Could not parse language's irc file [%s]: %s", ircName, err.Error())
665
+				}
669 666
 
670
-			for key, value := range tlList {
671
-				// because of how crowdin works, this is how we skip untranslated lines
672
-				if key == value || value == "" {
673
-					continue
667
+				for key, value := range tlList {
668
+					// because of how crowdin works, this is how we skip untranslated lines
669
+					if key == value || value == "" {
670
+						continue
671
+					}
672
+					langInfo.Translations[key] = value
674 673
 				}
675
-				langInfo.Translations[key] = value
676 674
 			}
677 675
 
678 676
 			// load help strings file
679 677
 			helpName := strings.TrimSuffix(name, ".lang.yaml") + "-help.lang.json"
680 678
 
681 679
 			data, err = ioutil.ReadFile(filepath.Join(config.Languages.Path, helpName))
682
-			if err != nil {
683
-				return nil, fmt.Errorf("Could not load language's help file [%s]: %s", helpName, err.Error())
684
-			}
685
-
686
-			err = json.Unmarshal(data, &tlList)
687
-			if err != nil {
688
-				return nil, fmt.Errorf("Could not parse language's help file [%s]: %s", helpName, err.Error())
689
-			}
680
+			if err == nil {
681
+				err = json.Unmarshal(data, &tlList)
682
+				if err != nil {
683
+					return nil, fmt.Errorf("Could not parse language's help file [%s]: %s", helpName, err.Error())
684
+				}
690 685
 
691
-			for key, value := range tlList {
692
-				// because of how crowdin works, this is how we skip untranslated lines
693
-				if key == value || value == "" {
694
-					continue
686
+				for key, value := range tlList {
687
+					// because of how crowdin works, this is how we skip untranslated lines
688
+					if key == value || value == "" {
689
+						continue
690
+					}
691
+					langInfo.Translations[key] = value
695 692
 				}
696
-				langInfo.Translations[key] = value
697 693
 			}
698 694
 
699 695
 			// confirm that values are correct

+ 1
- 1
irc/handlers.go Zobrazit soubor

@@ -806,7 +806,7 @@ func infoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
806 806
 	if 0 < len(tlines) {
807 807
 		rb.Add(nil, server.name, RPL_INFO, client.nick, client.t("Translators:"))
808 808
 		for _, line := range tlines {
809
-			rb.Add(nil, server.name, RPL_INFO, client.nick, "    "+line)
809
+			rb.Add(nil, server.name, RPL_INFO, client.nick, "    "+strings.Replace(line, "\n", ", ", -1))
810 810
 		}
811 811
 		rb.Add(nil, server.name, RPL_INFO, client.nick, "")
812 812
 	}

Načítá se…
Zrušit
Uložit