Skip to content

Commit

Permalink
Show full relative path for reference source text files
Browse files Browse the repository at this point in the history
Instead of showing just the base name (e.g. "[messages.json]"), use
relative path (e.g. "[../en/messages.json]").

This makes a difference in the not-uncommon setup where the filename is
the same, but located in an adjacent folder.
  • Loading branch information
vslavik committed Sep 14, 2024
1 parent a5669a4 commit 12d0cd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/edframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2497,18 +2497,23 @@ void PoeditFrame::OfferSideloadingSourceText()
if (!Language::TryGuessFromFilename(filename, &wildcard).IsValid())
return;

wxFileName fn(filename);

wildcard.Replace("*", "en");
wxFileName ref(wildcard);
if (!ref.FileExists() || wxFileName(filename) == ref)
if (!ref.FileExists() || fn == ref)
return;

wxFileName displayRef(ref);
displayRef.MakeRelativeTo(fn.GetPath());

AttentionMessage msg
(
"sideload-symbolic-id-source",
AttentionMessage::Question,
_("Would you like to use English for source text?")
);
msg.SetExplanation(wxString::Format(_(L"This file uses string IDs instead of source text. Poedit can load English texts from the “%s” file for you."), ref.GetFullName()));
msg.SetExplanation(wxString::Format(_(L"This file uses string IDs instead of source text. Poedit can load English texts from the “%s” file for you."), displayRef.GetFullPath()));
// TRANSLATORS: Shown as action button when asking if the user wants to replace string IDs with English text; "load" as in "load from file"
msg.AddAction(_("Load English"),[=]{
SideloadSourceTextFromFile(ref);
Expand Down
3 changes: 2 additions & 1 deletion src/edlistctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ void PoeditListCtrl::UpdateColumns()
if (m_catalog->HasSideloadedReferenceFile())
{
wxFileName fn(m_catalog->GetSideloadedSourceData()->reference_file->GetFileName());
sourceTitle += wxString::Format(" [%s]", fn.GetFullName());
fn.MakeRelativeTo(wxFileName(m_catalog->GetFileName()).GetPath());
sourceTitle += wxString::Format(" [%s]", fn.GetFullPath());
}
m_colSource->SetTitle(sourceTitle);

Expand Down

0 comments on commit 12d0cd8

Please sign in to comment.