mirror of
https://gitee.com/gitea/gitea
synced 2025-12-30 20:26:34 +08:00
Update go-ini dependency and remove semicolon hack in translations (#2913)
This commit is contained in:
29
vendor/gopkg.in/ini.v1/README.md
generated
vendored
29
vendor/gopkg.in/ini.v1/README.md
generated
vendored
@@ -101,7 +101,7 @@ skip-name-resolve
|
||||
By default, this is considered as missing value. But if you know you're going to deal with those cases, you can assign advanced load options:
|
||||
|
||||
```go
|
||||
cfg, err := LoadSources(LoadOptions{AllowBooleanKeys: true}, "my.cnf"))
|
||||
cfg, err := ini.LoadSources(ini.LoadOptions{AllowBooleanKeys: true}, "my.cnf"))
|
||||
```
|
||||
|
||||
The value of those keys are always `true`, and when you save to a file, it will keep in the same foramt as you read.
|
||||
@@ -125,7 +125,7 @@ If you want to save a value with `#` or `;`, please quote them with ``` ` ``` or
|
||||
Alternatively, you can use following `LoadOptions` to completely ignore inline comments:
|
||||
|
||||
```go
|
||||
cfg, err := LoadSources(LoadOptions{IgnoreInlineComment: true}, "app.ini"))
|
||||
cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, "app.ini"))
|
||||
```
|
||||
|
||||
### Working with sections
|
||||
@@ -329,6 +329,20 @@ foo = "some value" // foo: some value
|
||||
bar = 'some value' // bar: some value
|
||||
```
|
||||
|
||||
Sometimes you downloaded file from [Crowdin](https://crowdin.com/) has values like the following (value is surrounded by double quotes and quotes in the value are escaped):
|
||||
|
||||
```ini
|
||||
create_repo="created repository <a href=\"%s\">%s</a>"
|
||||
```
|
||||
|
||||
How do you transform this to regular format automatically?
|
||||
|
||||
```go
|
||||
cfg, err := ini.LoadSources(ini.LoadOptions{UnescapeValueDoubleQuotes: true}, "en-US.ini"))
|
||||
cfg.Section("<name of your section>").Key("create_repo").String()
|
||||
// You got: created repository <a href="%s">%s</a>
|
||||
```
|
||||
|
||||
That's all? Hmm, no.
|
||||
|
||||
#### Helper methods of working with values
|
||||
@@ -480,7 +494,7 @@ cfg.Section("package.sub").ParentKeys() // ["CLONE_URL"]
|
||||
Sometimes, you have sections that do not contain key-value pairs but raw content, to handle such case, you can use `LoadOptions.UnparsableSections`:
|
||||
|
||||
```go
|
||||
cfg, err := LoadSources(LoadOptions{UnparseableSections: []string{"COMMENTS"}}, `[COMMENTS]
|
||||
cfg, err := ini.LoadSources(ini.LoadOptions{UnparseableSections: []string{"COMMENTS"}}, `[COMMENTS]
|
||||
<1><L.Slide#2> This slide has the fuel listed in the wrong units <e.1>`))
|
||||
|
||||
body := cfg.Section("COMMENTS").Body()
|
||||
@@ -573,7 +587,7 @@ Why not?
|
||||
|
||||
```go
|
||||
type Embeded struct {
|
||||
Dates []time.Time `delim:"|"`
|
||||
Dates []time.Time `delim:"|" comment:"Time data"`
|
||||
Places []string `ini:"places,omitempty"`
|
||||
None []int `ini:",omitempty"`
|
||||
}
|
||||
@@ -581,10 +595,10 @@ type Embeded struct {
|
||||
type Author struct {
|
||||
Name string `ini:"NAME"`
|
||||
Male bool
|
||||
Age int
|
||||
Age int `comment:"Author's age"`
|
||||
GPA float64
|
||||
NeverMind string `ini:"-"`
|
||||
*Embeded
|
||||
*Embeded `comment:"Embeded section"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -605,10 +619,13 @@ So, what do I get?
|
||||
```ini
|
||||
NAME = Unknwon
|
||||
Male = true
|
||||
; Author's age
|
||||
Age = 21
|
||||
GPA = 2.8
|
||||
|
||||
; Embeded section
|
||||
[Embeded]
|
||||
; Time data
|
||||
Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00
|
||||
places = HangZhou,Boston
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user