"github.com/spf13/afero"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
+ "golang.org/x/text/transform"
+ "golang.org/x/text/unicode/norm"
"io"
"os"
"path/filepath"
}
}
+ // remove accents - see https://blog.golang.org/normalization
+ t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)
+ result, _, _ := transform.String(t, string(target))
+ return result
+
return string(target)
}
+func isMn(r rune) bool {
+ return unicode.Is(unicode.Mn, r) // Mn: nonspacing marks
+}
+
// ReplaceExtension takes a path and an extension, strips the old extension
// and returns the path with the new extension.
func ReplaceExtension(path string, newExt string) string {
{"FOo/BaR.html", "FOo/BaR.html"},
{"трям/трям", "трям/трям"},
{"은행", "은행"},
- {"Ð\91анковÑ\81кий каÑ\81Ñ\81иÑ\80", "Ð\91анковÑ\81кий-кассир"},
+ {"Ð\91анковÑ\81кий каÑ\81Ñ\81иÑ\80", "Ð\91анковÑ\81кии-кассир"},
}
for _, test := range tests {
{testDir + "FOo/BaR.html", dir + testDir + "FOo/BaR.html" + FilePathSeparator},
{testDir + "трям/трям", dir + testDir + "трям/трям" + FilePathSeparator},
{testDir + "은행", dir + testDir + "은행" + FilePathSeparator},
- {testDir + "Ð\91анковÑ\81кий каÑ\81Ñ\81иÑ\80", dir + testDir + "Ð\91анковÑ\81кий-кассир" + FilePathSeparator},
+ {testDir + "Ð\91анковÑ\81кий каÑ\81Ñ\81иÑ\80", dir + testDir + "Ð\91анковÑ\81кии-кассир" + FilePathSeparator},
}
for _, test := range tests {