mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 12:47:47 -04:00 
			
		
		
		
	Update go-ini dependency and remove semicolon hack in translations (#2913)
This commit is contained in:
		
							
								
								
									
										12
									
								
								vendor/github.com/Unknwon/i18n/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								vendor/github.com/Unknwon/i18n/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| .PHONY: build test bench vet | ||||
|  | ||||
| build: vet bench | ||||
|  | ||||
| test: | ||||
| 	go test -v -cover | ||||
|  | ||||
| bench: | ||||
| 	go test -v -cover -test.bench=. -test.benchmem | ||||
|  | ||||
| vet: | ||||
| 	go vet | ||||
							
								
								
									
										6
									
								
								vendor/github.com/Unknwon/i18n/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/Unknwon/i18n/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| i18n | ||||
| i18n [](https://godoc.org/github.com/Unknwon/i18n) [](https://sourcegraph.com/github.com/Unknwon/i18n?badge) | ||||
| ==== | ||||
|  | ||||
| Package i18n is for app Internationalization and Localization. | ||||
| @@ -131,4 +131,6 @@ This command can operate 1 or more files in one command. | ||||
|  | ||||
| ## More information | ||||
|  | ||||
| If the key does not exist, then i18n will return the key string to caller. For instance, when key name is `hi` and it does not exist in locale file, simply return `hi` as output. | ||||
| - The first locale you load to the module is considered as **default locale**. | ||||
| - When matching non-default locale and didn't find the string, i18n will have a second try on default locale. | ||||
| - If i18n still cannot find string in the default locale, raw string will be returned. For instance, when the string is `hi` and it does not exist in locale file, simply return `hi` as output. | ||||
|   | ||||
							
								
								
									
										32
									
								
								vendor/github.com/Unknwon/i18n/i18n.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/github.com/Unknwon/i18n/i18n.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -156,7 +156,10 @@ func GetDescriptionByLang(lang string) string { | ||||
| } | ||||
|  | ||||
| func SetMessageWithDesc(lang, langDesc string, localeFile interface{}, otherLocaleFiles ...interface{}) error { | ||||
| 	message, err := ini.Load(localeFile, otherLocaleFiles...) | ||||
| 	message, err := ini.LoadSources(ini.LoadOptions{ | ||||
| 		IgnoreInlineComment:         true, | ||||
| 		UnescapeValueCommentSymbols: true, | ||||
| 	}, localeFile, otherLocaleFiles...) | ||||
| 	if err == nil { | ||||
| 		message.BlockMode = false | ||||
| 		lc := new(locale) | ||||
| @@ -194,10 +197,11 @@ func (l Locale) Index() int { | ||||
| // Tr translates content to target language. | ||||
| func Tr(lang, format string, args ...interface{}) string { | ||||
| 	var section string | ||||
| 	parts := strings.SplitN(format, ".", 2) | ||||
| 	if len(parts) == 2 { | ||||
| 		section = parts[0] | ||||
| 		format = parts[1] | ||||
|  | ||||
| 	idx := strings.IndexByte(format, '.') | ||||
| 	if idx > 0 { | ||||
| 		section = format[:idx] | ||||
| 		format = format[idx+1:] | ||||
| 	} | ||||
|  | ||||
| 	value, ok := locales.Get(lang, section, format) | ||||
| @@ -208,15 +212,17 @@ func Tr(lang, format string, args ...interface{}) string { | ||||
| 	if len(args) > 0 { | ||||
| 		params := make([]interface{}, 0, len(args)) | ||||
| 		for _, arg := range args { | ||||
| 			if arg != nil { | ||||
| 				val := reflect.ValueOf(arg) | ||||
| 				if val.Kind() == reflect.Slice { | ||||
| 					for i := 0; i < val.Len(); i++ { | ||||
| 						params = append(params, val.Index(i).Interface()) | ||||
| 					} | ||||
| 				} else { | ||||
| 					params = append(params, arg) | ||||
| 			if arg == nil { | ||||
| 				continue | ||||
| 			} | ||||
|  | ||||
| 			val := reflect.ValueOf(arg) | ||||
| 			if val.Kind() == reflect.Slice { | ||||
| 				for i := 0; i < val.Len(); i++ { | ||||
| 					params = append(params, val.Index(i).Interface()) | ||||
| 				} | ||||
| 			} else { | ||||
| 				params = append(params, arg) | ||||
| 			} | ||||
| 		} | ||||
| 		return fmt.Sprintf(format, params...) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user