Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 798
Muxor Avatar asked Oct 05 '18 05:10

Muxor


2 Answers

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:

  • Shell script to call: https://gist.github.com/letatas/221ea3d04e70996d026362de57c1b084
  • Swift script called by the first: https://gist.github.com/letatas/9a58ad4f0a979b19579334bd80516f4a

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.

like image 61
Zaphod Avatar answered Nov 16 '22 17:11

Zaphod


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.

like image 30
Mark Bridges Avatar answered Nov 16 '22 16:11

Mark Bridges