Skip to content

Commit 86fe5ae

Browse files
committed
Suggest foo.ext and en-US for sideloading of foo.$lang.ext too
This convention is used by RESX files primarily.
1 parent 8f0d556 commit 86fe5ae

1 file changed

Lines changed: 33 additions & 13 deletions

File tree

src/edframe.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,38 @@ void PoeditFrame::WarnAboutLanguageIssues()
24422442
}
24432443

24442444

2445+
namespace
2446+
{
2447+
2448+
wxFileName FindCandidateFileForSideloading(const wxFileName& thisFile, const wxString& wildcard)
2449+
{
2450+
for (auto candidate: {"en", "en.default", "default", "", "en-US"})
2451+
{
2452+
auto w(wildcard);
2453+
if (*candidate)
2454+
{
2455+
w.Replace("*", candidate);
2456+
}
2457+
else
2458+
{
2459+
// special-case complete removal of language code, e.g. using foo.resx as base
2460+
// for foo.*.resx (this is common for RESX in particular)
2461+
w.Replace(".*.", ".");
2462+
}
2463+
2464+
wxFileName fnw(w);
2465+
if (fnw.FileExists() && fnw != thisFile)
2466+
{
2467+
return fnw;
2468+
}
2469+
}
2470+
2471+
return {};
2472+
}
2473+
2474+
} // anonymous namespace
2475+
2476+
24452477
void PoeditFrame::OfferSideloadingSourceText()
24462478
{
24472479
if (!m_catalog->UsesSymbolicIDsForSource())
@@ -2453,19 +2485,7 @@ void PoeditFrame::OfferSideloadingSourceText()
24532485
return;
24542486

24552487
wxFileName fn(filename);
2456-
wxFileName ref;
2457-
2458-
for (auto candidate: {"en", "en.default", "default"})
2459-
{
2460-
auto w(wildcard);
2461-
w.Replace("*", candidate);
2462-
wxFileName fnw(w);
2463-
if (fnw.FileExists() && fnw != fn)
2464-
{
2465-
ref = fnw;
2466-
break;
2467-
}
2468-
}
2488+
wxFileName ref = FindCandidateFileForSideloading(fn, wildcard);
24692489
if (!ref.IsOk())
24702490
return;
24712491

0 commit comments

Comments
 (0)