Localizable.strings in a Flutter project?

Viewed 18

In a flutter app running on an iOS device, using the firebase_messaging package, when receiving a push notification via APNS that has a localized key, i.e. the alert part of the payload contains something like

"loc-key" : "GAME_PLAY_REQUEST_FORMAT",

the push notification will only display the key GAME_PLAY_REQUEST_FORMAT unless you do something to localize it on the device (cf. https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification or https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html). The standard way for this seems to be to add the key to the Localizable.strings. So the question presents itself:

How do you add Localizable.strings to an existing Flutter project?

1 Answers

So, what I ended up doing: Open the Flutter project in Xcode. Select the Runner in the navigator on the left, right click -> New File. Select Strings file, in the next window name it "Localizable". Create. Then, on the right in the utilities panel click the button "Localize..." Select the desired localizations (still in the utilities panel) and you're set to edit the respective files that have been created by Xcode.

Related