iOS Facebook SDK localization

前端 未结 4 604
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 08:14

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 a

相关标签:
4条回答
  • 2020-12-18 09:09

    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.

    0 讨论(0)
  • 2020-12-18 09:14

    As an update to the accepted answer here from Flo:

    For the latest Facebook SDK, the set of Facebook messages (and their identifying keys) has completely changed. For example, the "FBLV:LogInButton" key is no longer valid in the latest Fb SDK.

    Because of this my Facebook strings were no longer getting localized, until I realized this and replaced all my Facebook messages with the latest FacebookSDKStrings.bundle (v4.2) from https://github.com/facebook/facebook-ios-sdk -- I simply removed my original FacebookSDKOverrides.bundle and included this whole bundle FacebookSDKStrings.bundle as is in my project (including the Resources sub folder in there), updated my project .plist files to point to it, and with that all the Facebook strings got localized again.

    For example, the message for the default Login button label now looks like this:

    /* The long label for the FBSDKLoginButton when the user is currently logged out */
    "LoginButton.LogInLong" = "Log in with Facebook";
    

    Luckily, Facebook's GitHub page now includes translations for these messages for lots of languages already (which in my case meant I no longer needed to run these past my translators).

    0 讨论(0)
  • 2020-12-18 09:20

    As of Facebook SDK 4.9

    If you have downloaded the Facebook SDK, theres a bundle named "FacebookSDKStrings.bundle"

    1. add FacebookSDKStrings.bundle to your project
    2. make sure you enable Base Internalization as described in Apple's documentation.
    0 讨论(0)
  • 2020-12-18 09:21

    I just copied all string from "FacebookSDK.strings" from folder of langauge you want like fr.lproj to my poject Localizable.strings (French) ...This way worked for me...

    0 讨论(0)
提交回复
热议问题