When you use NSLocalizedString to localize text, you get a convenient <note> field exported in your XLIFF file, that gives your translators a useful message providing context for the string to be translated. For example:
<trans-unit id="%d file(s) remaining">
<source>%d file(s) remaining</source>
<note>Message shown for remaining files</note>
</trans-unit>
However, when you have a string in Interface Builder in Xcode, the <note> field in the exported XLIFF seems less than useful, like this:
<trans-unit id="ASb-3k-Fxs.title">
<source>Statistics</source>
<target>Statistics</target>
<note>Class = "UINavigationItem"; title = "Statistics"; ObjectID = "ASb-3k-Fxs";</note>
</trans-unit>
Xcode doesn't seem to use the Document Label or Document Notes from the Identity Inspector, which might provide more useful information.
Is there a way to change this note by developers in Xcode? Does Xcode depend on this note not changing? Anyone else have clients freaking out over the (perceived) complexity? :-) Thanks.
Is there a way to change this note by developers in Xcode?
I knew I’d seen this before somewhere but it took me a while to find it. There was a thread about this on the old DevForums.
That pointed to a bug (r. 20170304) which pointed to another bug (r. 18023555) which indicates that this is fixed in Xcode 7. And lo!, it is. The Notes field from the Document slice of the Identity inspector ends up in the
<note>
element within the XLIFF. For example:
<trans-unit id="KZR-8E-61i.title">
<source>Varnish</source>
<note>Class = "NSButtonCell"; title = "Varnish"; ObjectID = "KZR-8E-61i"; Note = "This button varnishes the selected waffle.";</note>
</trans-unit>
IMPORTANT If you’re working on OS X, make sure you set the note on the cell (NSButtonCell, NSTextFieldCell, and so on) rather than on the object itself. It’s the cell that gets exported to the XLIFF, so if you put the note on the object it doesn’t appear in the XLIFF.
iOS doesn’t have (the madness that is ;-) NSCell, so this isn’t a problem there.
Anyone else have clients freaking out over the (perceived) complexity?
Alas, this doesn’t help with that aspect of the issue.
Share and Enjoy
—
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"