Skip to content

Commit

Permalink
XLIFF: support resname/name attributes
Browse files Browse the repository at this point in the history
Handle 'resname' (XLIFF 1.2) and 'name' (XLIFF 2) attributes of
translation units and show them, if present, instead of the 'id'
attribute as the item's ID. These are meant to be used for symbolic,
human-readable identifiers, so are the appropriate thing to expose.

See #752.
  • Loading branch information
vslavik committed May 12, 2022
1 parent af2afc8 commit 4c4fef3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/catalog_xliff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,9 @@ class XLIFF12CatalogItem : public XLIFFCatalogItem
m_string = str::to_wx(extractor.extractedText);

// TODO: switch to textual IDs in CatalogItem
std::string id = node.attribute("id").value();
std::string id = node.attribute("resname").value();
if (id.empty())
id = node.attribute("id").value();
// some tools (e.g. Xcode, tool-id="com.apple.dt.xcode") use ID same as text
if (!id.empty() && id != m_string)
m_extractedComments.push_back("ID: " + str::to_wx(id));
Expand Down Expand Up @@ -757,7 +759,9 @@ class XLIFF2CatalogItem : public XLIFFCatalogItem
m_string = str::to_wx(extractor.extractedText);

// TODO: switch to textual IDs in CatalogItem
std::string id = unit().attribute("id").value();
std::string id = unit().attribute("name").value();
if (id.empty())
id = unit().attribute("id").value();
// some tools (e.g. Xcode, tool-id="com.apple.dt.xcode") use ID same as text
if (!id.empty() && id != m_string)
m_extractedComments.push_back("ID: " + str::to_wx(id));
Expand Down

0 comments on commit 4c4fef3

Please sign in to comment.