'Xcode 10 - How to refresh localization of a Siri shortcut intent definition file?

I have an intent definition file for a Siri shortcut. When I click on localize Xcode does very well create a localization file, each string beeing used is present with an ID. But how do I refresh this if I added a new intent in the same file or just added a new possible response to the same file? I currently only found two ways:

  • Delete localization and set up new again (which makes you loose all translated strings in all languages besides default).
  • Export all translations for the whole app and reimport (which leads to problems if your complete app is not yet ready for new localization export/import).

So, does anybody know a way to refresh the auto-localization of an intents definition file?



Solution 1:[1]

I ran into the same problem lately, and I managed to fix it with a simple workaround and two small, quick and dirty scripts:

  1. Be sure to have your old localizations .strings files in your git repository
  2. Uncheck all your .intendefinition localizations (and delete them)
  3. Check back all your localizations, it will recreate the .strings files, but without your old translations (hopefully, they are safe in git)
  4. DO NOT COMMIT THEM (yet)
  5. For each .strings file run my little script this way: {script-path}/update-modified-strings-file.sh {project-path}/xx.lproj/YourIntents.strings
  6. Check if everything is ok
  7. Commit
  8. Live long and prosper...

Please be sure to put both scripts in the same directory:

The first script checks out the old version of the strings with your existing translations, the second merges the new file containing new entries with the old existing translations.

Hope this helps.

Solution 2:[2]

I have the same question, i played around with this exact thing tonight. From what i can see, i have to remove all localized files and recreate them, just like you said...

Solution 3:[3]

I wish Apple would fix with this.

In the meantime, the easiest way of dealing with it that I've found is this...

Add support for a new language in your project. For example, add Australian English. Then you'll get a new .strings file with all the new keys in it with the values from your intents definition.

Paste the contents of that into your existing English version and delete support for that new language.

If you want to get the new keys merged into your existing localised .strings files then you can use this https://github.com/Flinesoft/BartyCrouch Once it's installed you can run bartycrouch update and it'll sync the changes into all your .strings files.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Mathias
Solution 3 Mark Bridges