Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt README_{Country}.md stype name in localizedExtensions #21486

Merged
merged 30 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
68193c6
adapt README_{Contry}.md stype name in localizedExtensions
a1012112796 Oct 17, 2022
9cb175e
fix test
a1012112796 Oct 17, 2022
e257383
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 17, 2022
c6b552d
Merge branch 'main' into zzc/dev/readme_link
a1012112796 Oct 18, 2022
54db32c
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 18, 2022
acb6eb2
Merge branch 'main' into zzc/dev/readme_link
a1012112796 Oct 18, 2022
428321d
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 18, 2022
181d6b5
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 18, 2022
338bd3d
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 18, 2022
ed935b2
Update routers/web/repo/view.go
a1012112796 Oct 19, 2022
50bc00e
Merge branch 'main' into zzc/dev/readme_link
a1012112796 Oct 19, 2022
8ecc357
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 19, 2022
b3f9f26
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 19, 2022
9618c87
make fmt
a1012112796 Oct 19, 2022
f67b89f
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 19, 2022
fbe9a2b
Merge branch 'main' into zzc/dev/readme_link
a1012112796 Oct 19, 2022
a98877d
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 20, 2022
578f24f
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 21, 2022
6eeed55
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 21, 2022
5df8489
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 21, 2022
27348eb
Merge branch 'main' into zzc/dev/readme_link
a1012112796 Oct 22, 2022
a194de5
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 22, 2022
bfff503
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 22, 2022
b2e3293
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 22, 2022
b26d945
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 23, 2022
db34de1
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 23, 2022
f59d31f
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 23, 2022
08350f4
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 23, 2022
487af90
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 24, 2022
d5c4780
Merge branch 'main' into zzc/dev/readme_link
lunny Oct 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func localizedExtensions(ext, languageCode string) (localizedExts []string) {
if strings.Contains(lowerLangCode, "-") {
underscoreLangCode := strings.ReplaceAll(lowerLangCode, "-", "_")
indexOfDash := strings.Index(lowerLangCode, "-")
// e.g. [.zh-cn.md, .zh_cn.md, .zh.md, .md]
return []string{lowerLangCode + ext, underscoreLangCode + ext, lowerLangCode[:indexOfDash] + ext, ext}
// e.g. [.zh-cn.md, .zh_cn.md, .zh.md, _zh.md, .md]
return []string{lowerLangCode + ext, underscoreLangCode + ext, lowerLangCode[:indexOfDash] + ext, strings.Replace(lowerLangCode[:indexOfDash]+ext, ".", "_", 1), ext}
a1012112796 marked this conversation as resolved.
Show resolved Hide resolved
}

// e.g. [.en.md, .md]
Expand Down
6 changes: 3 additions & 3 deletions routers/web/repo/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ func Test_localizedExtensions(t *testing.T) {
name: "With region - lowercase",
languageCode: "en-us",
ext: ".md",
wantLocalizedExts: []string{".en-us.md", ".en_us.md", ".en.md", ".md"},
wantLocalizedExts: []string{".en-us.md", ".en_us.md", ".en.md", "_en.md", ".md"},
},
{
name: "With region - uppercase",
languageCode: "en-CA",
ext: ".MD",
wantLocalizedExts: []string{".en-ca.MD", ".en_ca.MD", ".en.MD", ".MD"},
wantLocalizedExts: []string{".en-ca.MD", ".en_ca.MD", ".en.MD", "_en.MD", ".MD"},
},
{
name: "With region - all uppercase",
languageCode: "ZH-TW",
ext: ".md",
wantLocalizedExts: []string{".zh-tw.md", ".zh_tw.md", ".zh.md", ".md"},
wantLocalizedExts: []string{".zh-tw.md", ".zh_tw.md", ".zh.md", "_zh.md", ".md"},
},
}
for _, tt := range tests {
Expand Down