Xcode Localizable.stringsdict is not being included in .xliff when exporting for localization

735 views Asked by At

Just like the title says. I am using Xcode 8.3, and when I go to export a .xliff, it's not including the stuff in the localizable.stringsdict. I have selected the localizable.stringsdict and opened the file inspector and hit the big Localize button as well. That didn't seem to solve any problems. Does anyone have experience with this?

3

There are 3 answers

1
Lily Ballard On BEST ANSWER

I'm not sure if XLIFF is even capable of representing the contents of a stringsdict, but even if it is, as you've discovered Xcode does not include your stringsdict in the XLIFF output. Every translation service I've looked in to supports stringsdict files directly, so your solution is to just upload the stringsdict files along with the XLIFF to your translation service.

That said, it does seem like an oversight that when you export localizations Xcode doesn't at least copy the stringsdict files into the exported localizations folder alongside the xliff files. I recommend you file a bug report with Apple asking for this.

1
JKvr On

It works in Xcode 9.2, but I experienced some issues.

Currently my project have Base and sv localization. When I added localizable.stringsdict the content was not included in the XLIFF.

I then pressed Localize button, selected the only available language en (I was expecting Base here). Then I added sv as localization and did Export for localization for sv- VoilĂ , it worked.

But a strange thing here is that the sv localization have en as its original.

<file original="Resources/en.lproj/Localizable.stringsdict" source-language="en" datatype="plaintext" target-language="sv">

(I tried adding Base as localization and remove the en-version, but then the Localizable.stringsdicts content was missing in the export)

0
Murray Sagal On

As of Xcode 14 it still seems to be not working. The Localizable.stringsdict file is indeed showing up in the xliff file but it is not represented correctly. Here's the plural rule defined in Localizable.stringsdict:

<key>Localized.numberOfPhotosSelected</key>
<dict>
    <key>NSStringLocalizedFormatKey</key>
    <string>%#@VARIABLE@</string>
    <key>VARIABLE</key>
    <dict>
        <key>NSStringFormatSpecTypeKey</key>
        <string>NSStringPluralRuleType</string>
        <key>NSStringFormatValueTypeKey</key>
        <string>u</string>
        <key>one</key>
        <string>%u Photo selected</string>
        <key>other</key>
        <string>%u Photos selected</string>
    </dict>
</dict>

And here's how it's showing up in the xliff:

  <trans-unit id="/Localized.numberOfPhotosSelected:dict/NSStringLocalizedFormatKey:dict/:string" xml:space="preserve">
    <source>%#@VARIABLE@</source>
    <target>%#@VARIABLE@</target>
    <note>This is the text of a label that shows the user how many photos have been selected. The key references a plural rule defined in the strings dictionary. The rule will respond to the actual number of photos and return the correct pluralization of 'photo'.</note>
  </trans-unit>
  <trans-unit id="/Localized.numberOfPhotosSelected:dict/VARIABLE:dict/other:dict/:string" xml:space="preserve">
    <source>%u Photos selected</source>
    <target>%u Photos selected</target>
    <note>This is the text of a label that shows the user how many photos have been selected. The key references a plural rule defined in the strings dictionary. The rule will respond to the actual number of photos and return the correct pluralization of 'photo'.</note>
  </trans-unit>

Notice that the "one" rule is not represented. guru_meditator's comment probably still holds true.

Thankfully we don't have too many so we'll just do the plurals manually.