How can I use container apps localized strings from shared extension in Swift. I have already added containers strings files into extension -> build phase -> compile sources
but its still not working. Should I set anything in configuration? From main container app strings are translated but from shared extension it shows only the string keys/ids for texts.
Asked
Active
Viewed 3,449 times
6

Sazzad Hissain Khan
- 37,929
- 33
- 189
- 256
-
check this one please https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionCreation.html – Nazmul Hasan Sep 06 '16 at 06:15
-
which part of the article are you referring for localization issue? I have already gone through the post. @NazmulHasan – Sazzad Hissain Khan Sep 06 '16 at 06:23
-
may be problem is your Localizable.strings? – Nazmul Hasan Sep 06 '16 at 06:35
-
try with this tutorial https://www.youtube.com/watch?v=YpNU6HbkMjQ&feature=youtu.be – Nazmul Hasan Sep 06 '16 at 06:36
-
did you solve your problem ? – Nazmul Hasan Sep 06 '16 at 09:14
-
1Can you please explain here in the answer. I have no access in youtube from office. Please explain the steps if you know. @NazmulHasan – Sazzad Hissain Khan Sep 06 '16 at 10:30
2 Answers
13
You need to change target membership of the Localizable.strings file. Select Localizable.strings in the Project Navigator on the left, then open File Inspector on the right and add checkmark next to your extension target in the "Target Membership" field.

ovejka
- 999
- 1
- 16
- 21
-
Thank you so much @ovejka. Now its working fine. Thanks again. – Sazzad Hissain Khan Sep 15 '16 at 09:40
0
There are a couple things to check:
- One is the solution offered here by @ovejka - click on your string localization file and ensure, in the rightside settings pane, that the file applies to your widget as well as your main app (target membership).
- Another is to ensure that your storyboard strings file, which should have been created automatically when you added a second language to your app, has the proper translations.
- If neither of those work, given that a widget is quite small and likely only has few labels, you could add a switch statement to 'viewWillAppear' to translate each label based on the detected language
Finally, none of those seemed to be working for me in the simulator or even by switching the schema language and running it on my actual phone.
It turns out, it was working all along and the simulated language wasn't applying to the widget. I turned my actual phone's language to Spanish, run the new version of my app, and the widget was translated.

Dave G
- 12,042
- 7
- 57
- 83