-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
94 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
{ | ||
{.locale.Tr "wa.footer_agreement" | Str2html}} | ||
{{.locale.Tr "wa.footer_agreement" | Str2html}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module example/locale | ||
|
||
go 1.20 | ||
|
||
require github.com/go-ini/ini v1.67.0 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= | ||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
|
||
"github.com/go-ini/ini" | ||
) | ||
|
||
func main() { | ||
|
||
// Define directory paths | ||
waLocalesDir := "/wa-locale" | ||
giteaLocalesDir := "/gitea-locale" | ||
outputDir := ("/custom/options/locale/") | ||
|
||
// Read custom locales | ||
customLocales, err := os.ReadDir(waLocalesDir) | ||
if err != nil { | ||
fmt.Println("Error reading custom locales directory:", err) | ||
os.Exit(1) | ||
} | ||
|
||
// Loop through each custom locale | ||
for _, waLocale := range customLocales { | ||
waLocalePath := path.Join(waLocalesDir, waLocale.Name()) | ||
giteaLocalePath := path.Join(giteaLocalesDir, waLocale.Name()) | ||
|
||
// Check if the base locale file exists | ||
if _, err := os.Stat(giteaLocalePath); err == nil { | ||
// Read custom data | ||
waLocaleData, err := ini.Load(waLocalePath) | ||
if err != nil { | ||
fmt.Println("Error loading custom data:", err) | ||
continue | ||
} | ||
|
||
// Read base data | ||
giteaLocaleData, err := ini.Load(giteaLocalePath) | ||
if err != nil { | ||
fmt.Println("Error loading base data:", err) | ||
continue | ||
} | ||
|
||
// Combine keys as specified | ||
for _, section := range waLocaleData.Sections() { | ||
for _, key := range section.Keys() { | ||
fmt.Println(key) | ||
// Add if not exists, and overwrite if does | ||
giteaLocaleData.Section(section.Name()).Key(key.Name()).SetValue(key.Value()) | ||
} | ||
} | ||
|
||
// Write the combined data to the output directory | ||
outputPath := path.Join(outputDir, waLocale.Name()) | ||
|
||
|
||
|
||
err = giteaLocaleData.SaveTo(outputPath) | ||
if err != nil { | ||
fmt.Println("Error saving combined data:", err) | ||
continue | ||
} | ||
|
||
fmt.Printf("Combined and saved %s to %s\n", waLocale.Name(), outputPath) | ||
} else { | ||
fmt.Printf("Base locale file not found for %s\n", waLocale.Name()) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.