2 Replies
      Latest reply on Aug 29, 2019 7:04 AM by startover205
      vmagalhaes Level 1 Level 1 (0 points)

        I'm trying to make sure that NSUserActivities that are donated get their string fields localized only when they're presented to the user. For example:

         

        userActivity.title = NSString.deferredLocalizedIntentsString("activity_title")

         

        The same applies for the suggestedInvocationPhrase variable.

         

        userActivity.suggestedInvocationPhrase = NSString.deferredLocalizedIntentsString("activity_suggested_phrase")

         

        The docs are not very clear about this usage of the API and it does not work as I was expecting.

        • Re: deferredLocalizedIntentsString
          siburb2 Level 1 Level 1 (0 points)

          Have you ever made any progress on this? We've been just using NSLocalizedString because this never worked properly, but would like to start using it now. It seems like it has never been fixed?

          When using `deferredLocalizedIntentsString` for the title of an NSUserActivity based shortcut, we just get the key as the title, and not the localized string. It seems to work for the suggested invocation phrase of a user activity based shortcut.

          When using `deferredLocalizedIntentsString` for the `suggestedInvocationPhrase` of an `INShortcut`, we just get the key as the suggested invocation phrase.




            • Re: deferredLocalizedIntentsString
              startover205 Level 1 Level 1 (0 points)

              Hi!  After some tests, I realized some rules to get it working. Hope these can help you!

               

              For example,

              NSString.deferredLocalizedIntentsString(with: "Start Activity")

               

              1.The deferred localization depends on the Siri's language settings, not the system's.

              2.The deferred localization looks up the phrase "Start Activity" on main app's "localizable.strings" file, not the app extensions'  or framework's.

              3.The "Start Activity" part won't be included in the xcatalog file generated by Xcode, so you have to use NSLocalizedString("Start Activity") somewhere in the code of main app.