Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Facebook SDK localization

I am trying to change text in FBLoginView button but I have no luck so far. I've tried to read README from FacebookSDK and look at internet. I added 2 languages in project Localizations sections it creates 2 files in Supporting files for each language but I tried to change strings in there with example content of README (with changed string values) but even if I changed english file I always get default login string. Then I tried to add some Bundle settings and change some files in there but with no luck too. Can someone tell me how can I achieve change facebook strings step by step? Thanks

like image 714
Libor Zapletal Avatar asked Nov 30 '22 02:11

Libor Zapletal


1 Answers

Update:

The method described here is no longer applicable for the latest Facebook SDKs. So please refer to the answers given by @Erik van der Neut or @Ted, and use the bundle FacebookSDKStrings.bundle that ships with the SDK for string overrides.


The only way I found so far to localize/change the Facebook strings is described in their FAQ: https://developers.facebook.com/docs/ios/troubleshooting/

What I did was to copy the file FacebookSDKOverrides.bundle from the Scrumptious sample project that ships with the Facebook SDK. This is basically just a package that contains (can contain) different localization folders. If you want to add German strings, create a folder de.lproj within the bundle. This folder should contain a file Localizable.strings.

You can find a list of all overrideable strings in the file FacebookSDKResources.bundle.README. You can find it in the FacebookSDK folder:

FacebookSDK.framework/Resources/

or here: https://github.com/facebook/facebook-ios-sdk/blob/master/src/FacebookSDKResources.bundle.README

To add a German translation of the text of the login button, for example, you have to add the following to the file Localizable.strings in de.lproj:

"FBLV:LogInButton" = "Einloggen";

As a last step, you have to make sure that Facebook knows about the bundle. Therefore, you can add the following to your Info.plist:

<key>FacebookBundleName</key>
<string>FacebookSDKOverrides</string> 

Alternatively, you can also specify this in code if you want to:

[FBSettings setResourceBundleName:@"FacebookSDKOverrides"];

This worked for me, although I would like to use my main bundle for overrides and just specify them in my normal app translations. This would come in more handy for the connection to translation tools as you don't need to translate multiple files per language.

like image 139
Flo Avatar answered Dec 04 '22 03:12

Flo